alex-plekhanov commented on a change in pull request #9821:
URL: https://github.com/apache/ignite/pull/9821#discussion_r808931264



##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/PlannerTest.java
##########
@@ -1299,4 +1308,110 @@ public void testNotStandardFunctions() throws Exception 
{
             checkSplitAndSerialization(phys, publicSchema);
         }
     }
+
+    /** */
+    @Test
+    public void testLongPlanningTimeout() throws Exception {
+        IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
+
+        TestTable t1 = new TestTable(
+            new RelDataTypeFactory.Builder(f)
+                .add("A", f.createJavaType(Integer.class))
+                .add("B", f.createJavaType(Integer.class))
+                .build()) {
+
+            @Override public IgniteDistribution distribution() {
+                return IgniteDistributions.broadcast();
+            }
+        };
+
+        TestTable t2 = new TestTable(
+            new RelDataTypeFactory.Builder(f)
+                .add("A", f.createJavaType(Integer.class))
+                .add("C", f.createJavaType(Integer.class))
+                .build()) {
+
+            @Override public IgniteDistribution distribution() {
+                return IgniteDistributions.broadcast();
+            }
+        };
+
+        TestTable t3 = new TestTable(
+            new RelDataTypeFactory.Builder(f)
+                .add("B", f.createJavaType(Integer.class))
+                .add("C", f.createJavaType(Integer.class))
+                .build()) {
+
+            @Override public IgniteDistribution distribution() {
+                return IgniteDistributions.broadcast();
+            }
+        };
+
+        TestTable t4 = new TestTable(
+            new RelDataTypeFactory.Builder(f)
+                .add("A", f.createJavaType(Integer.class))
+                .add("C", f.createJavaType(Integer.class))
+                .build()) {
+
+            @Override public IgniteDistribution distribution() {
+                return IgniteDistributions.broadcast();
+            }
+        };
+
+        IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
+
+        publicSchema.addTable("T1", t1);
+        publicSchema.addTable("T2", t2);
+        publicSchema.addTable("T3", t3);
+        publicSchema.addTable("T4", t4);
+
+        SchemaPlus schema = createRootSchema(false)
+            .add("PUBLIC", publicSchema);
+
+        String sql = "SELECT * FROM T1 JOIN T2 ON T1.A = T2.A JOIN T3 ON T3.B 
= T1.B AND T3.C = T2.C JOIN T4" +
+            " ON T4.C = T3.C AND T4.A = T1.A";
+
+        PlanningContext ctx = PlanningContext.builder()
+            .parentContext(BaseQueryContext.builder()
+                .frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
+                    .defaultSchema(schema)
+                    .costFactory(new IgniteCostFactory(1, 100, 1, 1))
+                    .build())
+                .logger(log)
+                .plannerTimeout(PLANNER_TIMEOUT)
+                .build()
+            )
+            .query(sql)
+            .build();
+
+        try (IgnitePlanner planner = ctx.planner()) {
+            assertNotNull(planner);
+
+            String qry = ctx.query();
+
+            assertNotNull(qry);
+
+            SqlNode sqlNode = planner.parse(qry);
+
+            ValidationResult validated = 
planner.validateAndGetTypeMetadata(sqlNode);
+
+            AtomicReference<IgniteRel> plan = new AtomicReference<>();
+
+            GridTestUtils.assertTimeout(2 * PLANNER_TIMEOUT, 
TimeUnit.MILLISECONDS, () -> {
+                plan.set(PlannerHelper.optimize(validated.sqlNode(), planner, 
log));
+            });
+
+            assertNotNull(plan.get());

Review comment:
       But in any case, you require previous to "optimize" steps. And in any 
case, you copy-paste them.




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