fangchenli commented on code in PR #23442:
URL: https://github.com/apache/datafusion/pull/23442#discussion_r3561463900


##########
datafusion/physical-plan/src/joins/cross_join.rs:
##########
@@ -102,23 +102,11 @@ pub struct CrossJoinExec {
 impl CrossJoinExec {
     /// Create a new [CrossJoinExec].
     pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> 
Self {
-        // left then right
-        let (all_columns, metadata) = {
-            let left_schema = left.schema();
-            let right_schema = right.schema();
-            let left_fields = left_schema.fields().iter();
-            let right_fields = right_schema.fields().iter();
-
-            let mut metadata = left_schema.metadata().clone();
-            metadata.extend(right_schema.metadata().clone());
-
-            (
-                left_fields.chain(right_fields).cloned().collect::<Fields>(),
-                metadata,
-            )
-        };
-
-        let schema = 
Arc::new(Schema::new(all_columns).with_metadata(metadata));
+        // Use the shared helper (inner join) so metadata merges the same way 
as
+        // the logical plan; merging it here independently let schemas diverge.
+        let (schema, _) =
+            build_join_schema(&left.schema(), &right.schema(), 
&JoinType::Inner);

Review Comment:
   A separate issue was opened for the pre-existing swap mismatch #23461



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