devinjdangelo commented on code in PR #9606:
URL: https://github.com/apache/arrow-datafusion/pull/9606#discussion_r1524897989


##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -129,14 +129,88 @@ impl Unparser<'_> {
                 Ok(())
             }
             LogicalPlan::Projection(p) => {
-                let items = p
-                    .expr
-                    .iter()
-                    .map(|e| self.select_item_to_sql(e))
-                    .collect::<Result<Vec<_>>>()?;
-                select.projection(items);
-
-                self.select_to_sql_recursively(p.input.as_ref(), query, 
select, relation)
+                // A second projection implies a derived tablefactor
+                if !select.already_projected() {

Review Comment:
   This block should probably be refactored into multiple helper functions to 
reduce cognitive load here...



-- 
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]

Reply via email to