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


##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/RecursiveCtePlannerTest.java:
##########
@@ -0,0 +1,184 @@
+/*
+ * 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.planner;
+
+import java.util.List;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Exchange;
+import org.apache.calcite.rel.core.Spool;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexScan;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteRecursiveTableScan;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.IgniteRepeatUnion;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteValues;
+import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.junit.Test;
+
+/** Planner tests for recursive common table expressions. */
+public class RecursiveCtePlannerTest extends AbstractPlannerTest {
+    /** Employee hierarchy query used for distribution and index planning 
checks. */
+    private static final String EMPLOYEE_HIERARCHY_QUERY =
+        "WITH RECURSIVE employee_hierarchy (id, manager_id, depth) AS (" +
+            "SELECT id, manager_id, 0 FROM employee WHERE manager_id IS NULL " 
+
+            "UNION ALL " +
+            "SELECT e.id, e.manager_id, h.depth + 1 " +
+            "FROM employee e " +
+            "JOIN employee_hierarchy h ON e.manager_id = h.id" +
+        ") " +
+        "SELECT id, manager_id, depth FROM employee_hierarchy";
+
+    /** Employee hierarchy query that requests indexed correlated lookups in 
the recursive term. */
+    private static final String INDEXED_EMPLOYEE_HIERARCHY_QUERY =
+        EMPLOYEE_HIERARCHY_QUERY
+            .replace("SELECT e.id", "SELECT /*+ CNL_JOIN */ e.id")
+            .replace("FROM employee e", "FROM employee /*+ 
FORCE_INDEX(EMPLOYEE_MANAGER_IDX) */ e");
+
+    /** Checks the physical operators used to maintain the recursive delta. */
+    @Test
+    public void testRecursiveDeltaPlan() throws Exception {
+        IgniteSchema schema = new IgniteSchema(DEFAULT_SCHEMA);
+
+        IgniteRel plan = physicalPlan(
+            "WITH RECURSIVE numbers(n) AS (" +
+                "SELECT 1 " +
+                "UNION ALL " +
+                "SELECT n + 1 FROM numbers WHERE n < 3" +
+            ") " +
+            "SELECT n FROM numbers",
+            schema
+        );
+
+        assertRecursivePlan(plan);
+        IgniteRepeatUnion repeatUnion = findFirstNode(plan, 
byClass(IgniteRepeatUnion.class));
+
+        assertTrue(planDescription(plan), repeatUnion.getLeft() instanceof 
IgniteValues);
+        assertEquals(1, findNodes(plan, 
byClass(IgniteRecursiveTableScan.class)).size());
+
+        checkSplitAndSerialization(plan, schema);

Review Comment:
   I fixed it.



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