nuno-faria opened a new issue, #25545:
URL: https://github.com/apache/datafusion/issues/25545

   ### 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
   ```sql
   select *
   from (
       select a
       from t
   ) t2
   where a = 1
   ```
   
   is optimized to a plan like this
   ```sql
   SubqueryAlias: t2
     Filter: t.a = Int32(1)
       TableScan: t projection=[a]
   ```
   
   which is unparsed to
   ```sql
   SELECT * FROM t AS t2 WHERE (t.a = 1) -- t.a is invalid
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to