Skip to content

fix: continue an ARRAY JOIN's operand list across FROM commas - #80

Open
takaebato wants to merge 2 commits into
masterfrom
array-join-operand
Open

fix: continue an ARRAY JOIN's operand list across FROM commas#80
takaebato wants to merge 2 commits into
masterfrom
array-join-operand

Conversation

@takaebato

@takaebato takaebato commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

ClickHouse's comma after an ARRAY JOIN continues its operand list (ARRAY JOIN arr1 AS a, arr2 AS b unnests two arrays; a table can't follow there), but sqlparser parses each further operand as an independent FROM item — so the second operand surfaced as a phantom table read arr2 and its alias resolved as an ambiguous column. The single-operand special case (the operand is an array column of the left relation, not a scanned table) landed with the sqlparser 0.62 bump; the comma form stayed behind.

bind_from now tracks whether the previous FROM item's join chain ends in an ARRAY JOIN and binds a following bare-table item as another operand: a column read of the left relation, its alias exposed as the unnested element. A join-carrying or non-table item resets to the ordinary comma cross join, which is untouched — deliberately conservative: in the doubtful ARRAY JOIN a, b JOIN u ON … shape, b stays a table rather than risk demoting a real table to a column. A continued operand can also be an array-producing expression (arrayConcat(x, y) AS m — its argument columns read), and over a multi-table base the operand resolves open-world (Ambiguous, catalog-narrowable) like any unqualified column. No dialect gate — the construct itself pins the dialect family. The alias outputs trace to the operands at function granularity (each output to every operand); the exact zip pairing stays a per-function refinement, the same coarseness as UNNEST.

Tests

Column-level pins for the two- and three-operand forms (operands read as columns, no phantom table) and a table-level pin that the operand list stays out of table reads while an ordinary comma join keeps both tables. Full workspace: 931 tests, clippy and rustdoc clean.

🤖 Generated with Claude Code

ClickHouse's comma after an ARRAY JOIN continues its operand list — a
table can't follow — but sqlparser parses each further operand as an
independent FROM item, so ARRAY JOIN arr1 AS a, arr2 AS b surfaced
arr2 as a phantom table read (the single-operand special case landed
with the sqlparser 0.62 bump; the comma form stayed behind). bind_from
now tracks whether the previous item's join chain ended in an ARRAY
JOIN and binds a following bare-table item as an operand (a column
read of the left relation with its alias exposed); a join-carrying or
non-table item resets to the ordinary cross join. The alias outputs
trace to the operands at function granularity — the zip pairing stays
a per-function refinement, like UNNEST's.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR title follows the Conventional Commits spec.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.73%. Comparing base (c266e01) to head (48c1d91).

Files with missing lines Patch % Lines
sql-insight/src/resolver/binder/query.rs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #80      +/-   ##
==========================================
- Coverage   95.74%   95.73%   -0.01%     
==========================================
  Files          28       28              
  Lines        6675     6689      +14     
  Branches     6675     6689      +14     
==========================================
+ Hits         6391     6404      +13     
  Misses        191      191              
- Partials       93       94       +1     

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

Placement review of the operand-list continuation: a continued operand
can be an array-producing expression (its argument columns read), and
a join-carrying item deliberately stops the continuation — in the
doubtful ARRAY JOIN a, b JOIN u shape, b stays a table rather than
risk demoting a real table to a column. Multi-table bases resolve
operands open-world (Ambiguous, catalog-narrowable) and derived items
reset the state; probed healthy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.

1 participant