Repository navigation
[CALCITE-7814] Support the SQL-standard CYCLE clause in recursive CTEs - #5294
Conversation
92a7635 to
e7e736e
Compare
a16350a to
2a08d90
Compare
59717ae to
9136014
Compare
|
@vldpyatkov , thanks for this thorough, well-crafted PR. At this point I don't have any further comment, LGTM. |
|
Taking a final look... I have the impression that the current rewrite approach only works if Having a The first one fails, but the second one passes. A potential solution might be forcing the expansion (independently of the flag) in |
|
@rubenada Thanks for catching this! The rewrite now uses the expanded select list saved during validation, even when identifierExpansion is false. I also added tests covering both * and t.* with the flag enabled and disabled. |
|
Thanks @vldpyatkov . In order to prepare the final merge, could you please squash commits into a single one, keeping Jira number and title as final message: If no further comments are received, I'll merge this in the next 48h. |
f867774 to
b811d50
Compare
|



Jira Link
CALCITE-7814
Changes Proposed
The implemented CYCLE syntax
Explicit mark values must be distinct, non-null Boolean literals or compatible single-character string literals. Omitting TO ... DEFAULT ... uses TRUE and FALSE, respectively.
The clause is represented by SqlCycleClause on SqlWithItem. During validation, CycleRewriter rewrites the query to maintain the cycle mark and an ARRAY<ROW<...>> path. A row that closes a cycle is returned but is not expanded further.
During implementation, I found an issue with comparing ARRAY<ROW<...>> values and fixed the comparer to compare their elements by content. This is needed for correct duplicate elimination when the result includes a cycle path column.