zstan commented on code in PR #13559:
URL: https://github.com/apache/ignite/pull/13559#discussion_r3958572747


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java:
##########
@@ -178,6 +260,28 @@ public void 
testStateIsIsolatedBetweenSameNamedRecursiveCtes() {
             .check();
     }
 
+    /** */
+    @Test
+    public void testNestedRecursiveCteStatesAreIsolated() {
+        assertQuery("WITH RECURSIVE first_numbers(n) AS (" +
+                "SELECT 10 " +
+                "UNION ALL " +
+                "SELECT n + 1 FROM first_numbers WHERE n < 12" +
+            "), second_numbers(n) AS (" +
+                "SELECT 1 " +
+                "UNION ALL " +
+                "SELECT second_numbers.n + 1 " +
+                "FROM second_numbers " +
+                "JOIN first_numbers ON second_numbers.n + 9 = first_numbers.n 
" +
+                "WHERE second_numbers.n < 3" +
+            ") " +
+            "SELECT n FROM second_numbers")

Review Comment:
   do we need ordering ? 



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/RepeatUnionNode.java:
##########
@@ -155,6 +169,25 @@ private Node<Row> source() {
         return sources().get(curSrc);
     }
 
+    /** Binds recursive scans in this union's recursive term without crossing 
nested recursive unions. */
+    @SuppressWarnings("unchecked")

Review Comment:
   redundant ?



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/RecursiveCteIntegrationTest.java:
##########
@@ -115,6 +115,88 @@ public void testRecursiveTermWithMultipleSelfReferences() {
             .check();
     }
 
+    /** */
+    @Test
+    public void testRecursiveCteWithMultipleJoinConsumers() {
+        assertQuery("WITH RECURSIVE numbers(n) AS (" +
+                "SELECT 1 " +
+                "UNION ALL " +
+                "SELECT n + 1 FROM numbers WHERE n < 3" +
+            ") " +
+            "SELECT l.n, r.n " +
+            "FROM numbers l " +
+            "JOIN numbers r ON l.n = r.n")

Review Comment:
   \+ order by r.n ? 



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/RecursiveCteValidator.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query.calcite.prepare;
+
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlWith;
+import org.apache.calcite.sql.SqlWithItem;
+import org.apache.calcite.sql.util.SqlBasicVisitor;
+import org.apache.calcite.sql.validate.SqlValidatorNamespace;
+import org.apache.calcite.sql.validate.SqlWithItemTableRef;
+import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
+import org.apache.ignite.internal.processors.query.IgniteSQLException;
+
+/** Validates restrictions specific to recursive common table expressions. */
+final class RecursiveCteValidator {

Review Comment:
   can you fill appropriate issue in calcite and probably PR ?



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