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


##########
datafusion/physical-plan/src/union.rs:
##########
@@ -472,21 +472,20 @@ fn union_schema(inputs: &[Arc<dyn ExecutionPlan>]) -> 
SchemaRef {
         .map(|i| {
             inputs
                 .iter()
-                .filter_map(|input| {
-                    if input.schema().fields().len() > i {
-                        let field = input.schema().field(i).clone();
-                        let right_hand_metdata = inputs
-                            .get(1)
-                            .map(|right_input| {
-                                
right_input.schema().field(i).metadata().clone()
-                            })
-                            .unwrap_or_default();
-                        let mut metadata = field.metadata().clone();
-                        metadata.extend(right_hand_metdata);
-                        Some(field.with_metadata(metadata))
-                    } else {
-                        None
-                    }
+                .enumerate()
+                .map(|(input_idx, input)| {
+                    let field = input.schema().field(i).clone();
+                    let mut metadata = field.metadata().clone();
+
+                    let other_side_metdata = inputs
+                        .get(input_idx ^ (1 << 0))

Review Comment:
   FWIW @wiedld  told me that this basically "gets the other input" -- so if 
`inpux_index` is 0 this returns `1` and if `input_index` is `0` this returns 
`1`. 
   
   I believe she has plans to comment on this PR shortly



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