nathanb9 commented on code in PR #23442:
URL: https://github.com/apache/datafusion/pull/23442#discussion_r3560038463
##########
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:
nit: PR #16221 added `test_join_metadata` in both `joins/utils.rs` and the
logical `builder.rs` to pin the left-wins/right-wins convention per join type.
A matching unit test in `cross_join.rs` (construct a `CrossJoinExec` from two
inputs with conflicting schema metadata, assert output metadata equals the left
input's value) would be cheap to add and guards against future drift without
needing the full planning pipeline.
--
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]