This change ensures that table references which don't exist at their current level are removed. For example, SELECT ta.j1_id FROM (SELECT j1_id FROM j1 ta) is invalid because the subquery is un-aliased so ta is not a valid reference at the top-level projection.
This is usually caused by derived subqueries, both un-aliased and aliased.
What changes are included in this PR?
For each select_to_sql_expr, collects the available table identifiers at that level from the projection and table joins.
Iterates over the projection and order by and compares them to the list of collected identifiers. For identifiers that are not found, strips their table reference leaving just the bare column (e.g. ta.j1_id -> j1_id).
Are these changes tested?
Yes. A collection of new plan-to-SQL roundtrip tests to validate the changes.
Which issue does this PR close?
Closes #13027
Rationale for this change
This change ensures that table references which don't exist at their current level are removed. For example,
SELECT ta.j1_id FROM (SELECT j1_id FROM j1 ta)
is invalid because the subquery is un-aliased sota
is not a valid reference at the top-level projection.This is usually caused by derived subqueries, both un-aliased and aliased.
What changes are included in this PR?
select_to_sql_expr
, collects the available table identifiers at that level from the projection and table joins.ta.j1_id
->j1_id
).Are these changes tested?
Yes. A collection of new plan-to-SQL roundtrip tests to validate the changes.
Are there any user-facing changes?
No