Skip to content

[SPARK-56031][SQL] Make Natural Join column matching respect case sensitivity conf#54858

Closed
stefankandic wants to merge 2 commits intoapache:masterfrom
stefankandic:stefankandic/naturalJoinFix
Closed

[SPARK-56031][SQL] Make Natural Join column matching respect case sensitivity conf#54858
stefankandic wants to merge 2 commits intoapache:masterfrom
stefankandic:stefankandic/naturalJoinFix

Conversation

@stefankandic
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Use conf.resolver instead of case-sensitive Seq.intersect when computing common column names for NATURAL JOIN in the fixed-point Analyzer.

Why are the changes needed?

NATURAL JOIN uses case-sensitive string comparison to find common columns, ignoring spark.sql.caseSensitive (which defaults to false). This causes NATURAL JOIN to silently degrade to a CROSS JOIN when columns differ only in case (e.g., ID vs id).

The equivalent USING join already handles this correctly.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New unit and e2e tests in golden files.

Was this patch authored or co-authored using generative AI tooling?

No.

@stefankandic
Copy link
Copy Markdown
Contributor Author

@cloud-fan please take a look when you get a change

@cloud-fan
Copy link
Copy Markdown
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 2e7d0c9 Mar 18, 2026
terana pushed a commit to terana/spark that referenced this pull request Mar 23, 2026
…sitivity conf

### What changes were proposed in this pull request?
Use `conf.resolver` instead of case-sensitive `Seq.intersect` when computing common column names for `NATURAL JOIN` in the fixed-point Analyzer.

### Why are the changes needed?
`NATURAL JOIN` uses case-sensitive string comparison to find common columns, ignoring `spark.sql.caseSensitive` (which defaults to `false`). This causes `NATURAL JOIN` to silently degrade to a `CROSS JOIN` when columns differ only in case (e.g., `ID` vs `id`).

The equivalent `USING` join already handles this correctly.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
New unit and e2e tests in golden files.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes apache#54858 from stefankandic/stefankandic/naturalJoinFix.

Authored-by: Stefan Kandic <stefan.kandic@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants