Describe the bug
When a filter is based on a projected expression, the unparsing of the optimized plan can generate invalid SQL.
To Reproduce
The filter in the query below depends on a newly generated column
select *
from (
select random() as x
from t
)
where x = 1
which is optimized into this plan
Filter: x = Float64(1)
Projection: random() AS x
TableScan: t projection=[]
The unparsing of this plan puts the filter and the projection at the same level, which is invalid:
SELECT random() AS x FROM t WHERE (x = 1.0) -- Schema error: No field named x. Valid fields are t.a.
Expected behavior
No response
Additional context
No response
Describe the bug
When a filter is based on a projected expression, the unparsing of the optimized plan can generate invalid SQL.
To Reproduce
The filter in the query below depends on a newly generated column
which is optimized into this plan
The unparsing of this plan puts the filter and the projection at the same level, which is invalid:
Expected behavior
No response
Additional context
No response