vldpyatkov commented on code in PR #13479:
URL: https://github.com/apache/ignite/pull/13479#discussion_r3926168495


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java:
##########
@@ -43,18 +96,209 @@ public void testHierarchicalQueryIsNotSupported() {
             "FROM employee e " +
             "JOIN employee_hierarchy h ON e.manager_id = h.id" +
             ") " +
-            "SELECT id, manager_id, name, depth FROM employee_hierarchy ORDER 
BY depth, id";
+            "SELECT id, manager_id, name, depth FROM employee_hierarchy";
+
+        String plan = (String)sql("EXPLAIN PLAN FOR " + qry).get(0).get(0);
+
+        assertTrue(plan, plan.contains("IgniteRepeatUnion"));
+        assertTrue(plan, plan.contains("IgniteRecursiveTableScan"));
+        assertFalse(plan, plan.contains("IgniteRecursiveTableSpool"));
+    }
 
-        Throwable err = GridTestUtils.assertThrows(
-            log,
-            () -> sql(qry),
+    /** */
+    @Test
+    public void testRecursiveTermWithoutSelfReferenceAfterOptimization() {
+        assertQuery("WITH RECURSIVE numbers(n) AS (" +
+            "SELECT 1 " +
+            "UNION ALL " +
+            "SELECT n + 1 FROM numbers WHERE FALSE" +
+            ") " +
+            "SELECT n FROM numbers")
+            .returns(1)
+            .check();
+    }
+
+    /** */
+    @Test
+    public void testRecursiveTermWithMultipleSelfReferencesIsRejected() {
+        assertThrows(
+            "WITH RECURSIVE numbers(n) AS (" +
+                "SELECT 1 " +
+                "UNION ALL " +
+                "SELECT left_numbers.n + 1 " +
+                "FROM numbers left_numbers " +
+                "JOIN numbers right_numbers ON left_numbers.n = 
right_numbers.n " +
+                "WHERE left_numbers.n < 3" +
+            ") " +
+            "SELECT n FROM numbers",
+            IgniteSQLException.class,
+            "the recursive term must contain no more than one self-reference"

Review Comment:
   There is no strong technical reason for this limitation anymore.
   Removed this limitation, and tests finish without exception now:
   testRecursiveCteWithMultipleRecursiveBranchesIsRejected;
   testRecursiveTermWithMultipleSelfReferencesIsRejected



-- 
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]

Reply via email to