yyy1000 commented on code in PR #10494:
URL: https://github.com/apache/datafusion/pull/10494#discussion_r1600567694


##########
datafusion/optimizer/src/propagate_empty_relation.rs:
##########
@@ -154,14 +156,14 @@ impl OptimizerRule for PropagateEmptyRelation {
                         Ok(Transformed::yes(LogicalPlan::Projection(
                             Projection::new_from_schema(
                                 Arc::new(child),
-                                plan.schema().clone(),
+                                input_schema.clone(),
                             ),
                         )))
                     }
                 } else {
                     Ok(Transformed::yes(LogicalPlan::Union(Union {
                         inputs: new_inputs,
-                        schema: union.schema.clone(),
+                        schema: input_schema.clone(),

Review Comment:
   Oh, I see. It seems true.
   The current code will create the Union schema based on it's first input, 
https://github.com/apache/datafusion/blob/1d4b808c6f46bead241166fb1ed4646b3d17b01d/datafusion/expr/src/logical_plan/builder.rs#L1375-L1400.
 In the example, it's 'a', but later 'a' was removed, and the new input schema 
field would be 'test'.
   However I think this example may be a use case, based on the example a Union 
has two Project plan as inputs, how to coerce them seems a question for me. 🥲 
They already have different schemas and I can't know which one would be the 
merged schema.



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