rubenada commented on code in PR #5294:
URL: https://github.com/apache/calcite/pull/5294#discussion_r4216970188
##########
site/_docs/reference.md:
##########
@@ -522,6 +524,52 @@ MATCH_CONDITION left_table.timecol <= right_table.timecol
ON left_table.col = right_table.col
```
+### Cycle detection in recursive queries
Review Comment:
IIUC, the generated mark/path columns cannot be referenced in the recursive
term (not sure if the standard says something about this particular scenario).
I guess we do not need to support it, but probably it'd be worth adding some
tests in RecursiveCteTest showing this (see below) and clarify this
circumstance explicitly on this reference section?
```
@Test void testCycleMarkNotVisibleInRecursiveTerm() {
SqlValidatorTestCase.FIXTURE
.withSql("WITH RECURSIVE t(n) AS (VALUES (1)\n"
+ "UNION ALL SELECT n FROM t WHERE ^c^ = 'N')\n"
+ "CYCLE n SET c TO 'Y' DEFAULT 'N' USING p\n"
+ "SELECT * FROM t")
.fails("Column 'C' not found in any table");
}
@Test void testCyclePathNotVisibleInRecursiveTerm() {
SqlValidatorTestCase.FIXTURE
.withSql("WITH RECURSIVE t(n) AS (VALUES (1)\n"
+ "UNION ALL SELECT n FROM t WHERE CARDINALITY(^p^) < 3)\n"
+ "CYCLE n SET c TO 'Y' DEFAULT 'N' USING p\n"
+ "SELECT * FROM t")
.fails("Column 'P' not found in any table");
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]