alamb commented on code in PR #26790:
URL: https://github.com/apache/datafusion/pull/26790#discussion_r4392903340


##########
datafusion/physical-plan/src/union.rs:
##########
@@ -1016,31 +1016,29 @@ fn union_schema(inputs: &[Arc<dyn ExecutionPlan>]) -> 
Result<SchemaRef> {
             // which also uses the left side names.
             let base_field = first_schema.field(i).clone();
 
-            // Coerce metadata and nullability across all inputs
-
-            inputs
+            // Select the first nullable field, or the first field if none are
+            // nullable, before merging metadata. Otherwise, each non-nullable
+            // candidate would repeat the full metadata merge.
+            let (input_idx, input) = inputs

Review Comment:
   so I think my understanding is that this change effectively moves the check 
for `Field::isNullable` before the merging.
   
   This is likely to help in situations where a bunch of non nullable inputs 
are unioned into a nullable one that is far down the list



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