blaginin opened a new issue, #15128: URL: https://github.com/apache/datafusion/issues/15128
### Describe the bug While working on https://github.com/apache/datafusion/pull/14781 I noticed that `UNNEST` is being transformed to sql incorrectly. For example, ```sql SELECT unnest([1, 2, 3, 4]) as second_unnest from unnest([1, 2, 3]) first_unnest; ``` is transformed into ```sql SELECT * FROM UNNEST([1, 2, 3]) AS first_unnest ``` ### To Reproduce ```rust let ctx = SessionContext::new(); let df = ctx .sql("SELECT unnest([1, 2, 3, 4]) as second_unnest from unnest([1, 2, 3]) first_unnest;") .await?; let dialect = CustomDialectBuilder::default() .with_unnest_as_table_factor(true) .build(); let unparser = Unparser::new(&dialect); let roundtrip_statement = unparser.plan_to_sql(&df.logical_plan())?; assert_eq!( format!("{}", roundtrip_statement), "SELECT * FROM UNNEST([1, 2, 3]) AS first_unnest" ); ``` ### Expected behavior Unnests should be preserved ### Additional context I think this is related to https://github.com/apache/datafusion/pull/13660 While fixing this, it would be good to not rely on having double alias, e.g.`Alias(Alias(Column(...` as I plan to remove it in https://github.com/apache/datafusion/pull/14781 -- 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.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