Skip to content

feat: Support parenthesized JOIN ... ON constraints in SQL - #28967

Merged
ritchie46 merged 1 commit into
mainfrom
fix/sql-parenthesized-join-on
Aug 25, 2026
Merged

ritchie46 merged 1 commit into
mainfrom
fix/sql-parenthesized-join-on

Conversation

@ritchie46

Copy link
Copy Markdown
Member

Quite a simple one, made with opus 5.

`process_join_constraint` matched `JoinConstraint::On` behind a pattern guard
on `SQLExpr::BinaryOp`. sqlparser wraps a parenthesized expression in
`SQLExpr::Nested`, which does not match that guard, so any `ON` clause with a
paren at its root fell through to the catch-all and bailed with "unsupported
SQL join constraint" — even for a single condition, `ON (a.x = b.x)`.

The guard was redundant: `process_join_on` already strips `Nested` recursively
and has its own catch-all with a more specific message. Removing it lets the
callee handle the case it was written for, and moves malformed-expression
errors from the constraint level down to the expression level where they
belong. The remaining variants reaching the outer catch-all (empty `USING`,
`None`) are still accurately described by its message.

The test list includes two forms that pass without this change: the root-level
`AND` of two parenthesized conditions, kept as a regression guard, and the
non-equi condition, which additionally covers the `join_where` path.

On TPC-DS this takes 54 of 99 queries from matching DuckDB to 58, and clears
the join constraint error on 6 more that then hit unrelated gaps (`ROLLUP`,
`sum(sum(x)) OVER`, date arithmetic, keyword table aliases).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2qrYK1WzWYdzKNgEHvQ7a
@github-actions github-actions Bot added A-sql Area: Polars SQL functionality enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The uncompressed lib size after this PR is 60.9927 MB.

@ritchie46
ritchie46 merged commit 06c4e50 into main Aug 25, 2026
31 of 33 checks passed
@ritchie46
ritchie46 deleted the fix/sql-parenthesized-join-on branch August 25, 2026 10:38
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.59%. Comparing base (586512b) to head (9073ec8).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28967      +/-   ##
==========================================
- Coverage   81.60%   81.59%   -0.02%     
==========================================
  Files        1889     1890       +1     
  Lines      268638   268755     +117     
  Branches     3264     3264              
==========================================
+ Hits       219233   219298      +65     
- Misses      48560    48612      +52     
  Partials      845      845              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-sql Area: Polars SQL functionality enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant