Skip to content

fix: Improve error message for metadata conflict in schema - #23952

Draft
mkleen wants to merge 1 commit into
apache:mainfrom
mkleen:improve-err-schema-mismatch
Draft

fix: Improve error message for metadata conflict in schema#23952
mkleen wants to merge 1 commit into
apache:mainfrom
mkleen:improve-err-schema-mismatch

Conversation

@mkleen

@mkleen mkleen commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Based on the discussion in #23461 we decided to just improves the error message, so the user knows there is a metadata conflict in the schema. It also reverts #23605, so CrossJoinExec has it's original behaviour. This changes a metadata conflict from a user perspective from:

select * from larger_table cross join smaller_table;

 DataFusion error: Internal error: PhysicalOptimizer rule 'join_selection' failed. Schema mismatch. Expected original schema: Field { "a": Int32 }, Field { "b": Int32 }, got new schema: Field { "a": Int32 }, Field { "b": Int32 }

to:

select * from larger_table cross join smaller_table;

DataFusion error: PhysicalOptimizer rule 'join_selection' failed. Schema mismatch caused by Internal error: Schema metadata mismatch: Expected original metadata: {"metadata_key": "right"}, got metadata: {"metadata_key": "left"}.

What changes are included in this PR?

  • Improve error message for schema validation in physical_planner.rs
  • Data creation in test_context.rs
  • Reproduction in slt
  • Revert behaviour of CrossJoinExec

Are these changes tested?

Yes

Are there any user-facing changes?

Yes, error message improved when the metadata has a conflict.

@github-actions github-actions Bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Jul 28, 2026
@mkleen mkleen changed the title Improve error message for metadata conflict in schema fix: Improve error message for metadata conflict in schema Jul 28, 2026
@mkleen
mkleen force-pushed the improve-err-schema-mismatch branch from 085db82 to ff90c42 Compare July 28, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Join swap in join_selection flips schema-level metadata, failing "Schema mismatch"

1 participant