Files
Alexey MilovidovandClaude Opus 4.8 5935608143 Address review: leave UNNEST(...) WITH ORDINALITY unchanged in arrayJoin rewrite
`UNNEST(...) WITH ORDINALITY` is valid PostgreSQL table-function syntax that
adds a 1-based ordinality column. `ARRAY JOIN` has no direct equivalent, and
`WITH` is not a clause keyword in `_NOT_AN_ALIAS`, so the omitted-`AS` alias
parser in `rewrite_arrayjoin_to_array_join` accepted the bare `WITH` token as
the table alias and emitted invalid ClickHouse SQL, e.g.

  SELECT * FROM t CROSS JOIN UNNEST(arr) WITH ORDINALITY AS u(x, n)

became

  SELECT * FROM t ARRAY JOIN arr AS WITH ORDINALITY AS u(x, n)

which would make the benchmark count a rewriter artifact as a ClickHouse query
failure. Add a guard that detects `WITH ORDINALITY` before alias parsing and
leaves the whole construct unchanged, consistent with the conservative handling
of other shapes `ARRAY JOIN` cannot represent (`RIGHT`/`FULL` joins, real `ON`
predicates, `USING` clauses). Add regression tests for `FROM`, `JOIN`,
`LEFT JOIN`, and lowercase forms, plus a sanity check that the plain
`UNNEST(arr) AS u(x)` rewrite is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-19 16:24:04 +00:00
..