Commit 97f499c
committed
ast: Preserve FROM clause ordering for mixed join/comma syntax
Fix table expression ordering when parsing mixed join/comma syntax like
`FROM t1 INNER JOIN t2, t3`. Previously, Readyset split table
expressions into separate `tables` and `join` fields without preserving
left-to-right order, breaking correlated subqueries (e.g., LATERAL)
that depend on earlier table expressions.
Solution: After encountering the first explicit join, convert subsequent
comma-separated tables to CROSS JOIN operators, preserving the
left-to-right evaluation order required by SQL semantics.
Example that now works:
FROM t1 INNER JOIN t2 AS TABLE2, LATERAL (SELECT ... FROM TABLE2)
Previously, LATERAL couldn't find TABLE2 because it was processed before
the joined table. Now the order is preserved: t1 → t2 → LATERAL.
Adds comprehensive logictests in `sqlparser/psql/from_clause_ordering.test`
to prevent regression.
Release-Note-Core: Correlated subquery resolution in mixed join/comma
syntax.
AI-Use: level:3
Change-Id: I7cb724b5451c371840647ca9c689883afac76f1b
Reviewed-on: https://gerrit.readyset.name/c/readyset/+/11063
Reviewed-by: Vassili Zarouba <vassili@readyset.io>
Tested-by: Buildkite CI1 parent ee6f2d6 commit 97f499c
File tree
2 files changed
+66
-2
lines changed- logictests/sqlparser/psql
- readyset-sql/src/ast
2 files changed
+66
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
512 | | - | |
513 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
514 | 533 | | |
515 | 534 | | |
516 | 535 | | |
| |||
0 commit comments