mihaibudiu commented on code in PR #4704:
URL: https://github.com/apache/calcite/pull/4704#discussion_r2649275820


##########
core/src/test/resources/sql/hep.iq:
##########
@@ -149,6 +150,37 @@ EnumerableCalc(expr#0..3=[{inputs}], MGR=[$t1], COMM=[$t2])
       EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t6):DECIMAL(12, 2)], 
expr#9=[5.00:DECIMAL(12, 2)], expr#10=[>($t8, $t9)], expr#11=[IS NOT 
NULL($t3)], expr#12=[AND($t10, $t11)], MGR=[$t3], $condition=[$t12])
         EnumerableTableScan(table=[[scott, EMP]])
 !plan
+!}
+
+!if (enable_new_decorrelator) {
+SELECT e1.mgr, e1.comm
+FROM emp e1
+WHERE e1.mgr > 12
+  AND EXISTS (
+    SELECT 1
+    FROM emp e2
+    WHERE e2.mgr = e1.mgr
+      AND e2.comm > 5);
++------+---------+
+| MGR  | COMM    |
++------+---------+
+| 7698 |    0.00 |
+| 7698 | 1400.00 |
+| 7698 |  300.00 |
+| 7698 |  500.00 |
+| 7698 |         |
++------+---------+
+(5 rows)
+
+!ok
+EnumerableCalc(expr#0..2=[{inputs}], MGR=[$t1], COMM=[$t2])
+  EnumerableHashJoin(condition=[IS NOT DISTINCT FROM($1, $4)], joinType=[semi])
+    EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t3):INTEGER], 
expr#9=[12], expr#10=[>($t8, $t9)], EMPNO=[$t0], MGR=[$t3], COMM=[$t6], 
$condition=[$t10])
+      EnumerableTableScan(table=[[scott, EMP]])
+    EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t6):DECIMAL(12, 2)], 
expr#9=[5.00:DECIMAL(12, 2)], expr#10=[>($t8, $t9)], expr#11=[IS NOT 
NULL($t3)], expr#12=[AND($t10, $t11)], EMPNO=[$t0], MGR=[$t3], COMM=[$t6], 
$condition=[$t12])
+      EnumerableTableScan(table=[[scott, EMP]])
+!plan

Review Comment:
   Ideally the new decorrelator would make !plan always pass (by essentially 
ignoring the output), but I am not sure this is even possible with the way 
quidem works



##########
core/src/main/java/org/apache/calcite/tools/Programs.java:
##########
@@ -259,7 +260,26 @@ public static Program subQuery(RelMetadataProvider 
metadataProvider) {
             CoreRules.PROJECT_SUB_QUERY_TO_CORRELATE,
             CoreRules.JOIN_SUB_QUERY_TO_CORRELATE,
             CoreRules.PROJECT_OVER_SUM_TO_SUM0_RULE));
-    return of(builder.build(), true, metadataProvider);
+    final Program oldProgram = of(builder.build(), true, metadataProvider);
+
+    final HepProgramBuilder newBuilder = HepProgram.builder();
+    newBuilder.addRuleCollection(

Review Comment:
   Do these cover all subquery cases?
   I am not sure why the SUM rule is here.



##########
core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java:
##########
@@ -315,19 +319,21 @@ public class ViewExpanderImpl implements ViewExpander {
     final RexBuilder rexBuilder = createRexBuilder();
     final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
     final SqlToRelConverter.Config config =
-        sqlToRelConverterConfig.withTrimUnusedFields(false);
+        sqlToRelConverterConfig.withTrimUnusedFields(false)

Review Comment:
   I would align the with() each on a new line



##########
core/src/test/java/org/apache/calcite/test/CoreQuidemTest2.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.calcite.test;
+
+import org.apache.calcite.config.CalciteConnectionProperty;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Test that runs Quidem files with the top-down decorrelator enabled.
+ */
+public class CoreQuidemTest2 extends CoreQuidemTest {
+  /** Runs a test from the command line.
+   *
+   * <p>For example:
+   *
+   * <blockquote>
+   *   <code>java CoreQuidemTest2 sql/dummy.iq</code>
+   * </blockquote> */
+  public static void main(String[] args) throws Exception {
+    for (String arg : args) {
+      new CoreQuidemTest2().test(arg);
+    }
+  }
+
+  @Override protected Collection<String> data() {
+    final List<String> paths = new ArrayList<>(super.data());
+    paths.remove("sql/agg.iq");

Review Comment:
   I would comment that these are temporary and will eventually be removed



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