Describe the bug
When unparsing a plan with a SubqueryAlias + FilterExec, the resulting SQL can be invalid, since the alias will be applied to the base table while the filter still refers to the previous table name.
To Reproduce
This query
select *
from (
select a
from t
) t2
where a = 1
is optimized to a plan like this
SubqueryAlias: t2
Filter: t.a = Int32(1)
TableScan: t projection=[a]
which is unparsed to
SELECT * FROM t AS t2 WHERE (t.a = 1) -- t.a is invalid
Expected behavior
No response
Additional context
No response
Describe the bug
When unparsing a plan with a
SubqueryAlias+FilterExec, the resulting SQL can be invalid, since the alias will be applied to the base table while the filter still refers to the previous table name.To Reproduce
This query
is optimized to a plan like this
which is unparsed to
Expected behavior
No response
Additional context
No response