> If yes, is there a way we can get the final transformed query?
See debug_print_parse and friends [1]. Depending on what you mean by "final transformed query", you might instead want debug_print_rewritten, or maybe you want the plan, in which case EXPLAIN is a much friendlier way to look at it than debug_print_plan.