y-f-u opened a new pull request, #11505: URL: https://github.com/apache/datafusion/pull/11505
## Which issue does this PR close? Unparser creates invalid sqls for LogicPlan that generated from sql with derived table with columns. ## Rationale for this change See "Which issue does this PR close", also check below comment. Copy/pasted from the code comments. ``` // A roundtrip example for table alias with columns // // query: SELECT id FROM (SELECT j1_id from j1) AS c (id) // // LogicPlan: // Projection: c.id // SubqueryAlias: c // Projection: j1.j1_id AS id // Projection: j1.j1_id // TableScan: j1 // // Before introducing this logic, the unparsed query would be `SELECT c.id FROM (SELECT j1.j1_id AS // id FROM (SELECT j1.j1_id FROM j1)) AS c`. // The query is invalid as `j1.j1_id` is not a valid identifier in the derived table // `(SELECT j1.j1_id FROM j1)` ``` ## What changes are included in this PR? Introduce a method that probe the SubqueryAlias plan to see if it contains a double layer of projections. If so, extract column alias from the outer layer projection into table alias and use the inner layer projection for relation construction. ## Are these changes tested? Yes ## Are there any user-facing changes? No -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org