wiedld commented on code in PR #12142:
URL: https://github.com/apache/datafusion/pull/12142#discussion_r1730651101


##########
datafusion/expr/src/logical_plan/builder.rs:
##########
@@ -1331,7 +1331,17 @@ pub fn validate_unique_names<'a>(
     })
 }
 
-/// Union two logical plans.
+/// Union two [`LogicalPlan`]s.
+///
+/// Constructs the UNION plan, but does not perform type-coercion. Therefore 
the
+/// subtree expressions will not be properly typed until the optimizer pass.

Review Comment:
   Also, to clarify. The "incorrect plans" is because the new `union()` 
behavior doesn't type-coerce the expressions and it [takes the left node's 
schema](https://github.com/apache/datafusion/blob/4fd460d7a2d2b60e6f9dc716148d8596d94d048c/datafusion/expr/src/logical_plan/builder.rs#L1346-L1352).
 When we built logical plans with union + gap filling (adding casted scalar 
nulls), we started having missing fields etc when inspecting the union before 
constructing the next node.
   
   Maybe the latter should be a bug?



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

Reply via email to