jamesstarr commented on a change in pull request #2138:
URL: https://github.com/apache/calcite/pull/2138#discussion_r496353320



##########
File path: core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
##########
@@ -4029,6 +4029,88 @@ private Tester getExtendedTester() {
     sql(sql).trim(true).ok();
   }
 
+  @Test void testJoinExpandAndDecorrelation() {
+    String sql = ""
+        + "SELECT emp.deptno, emp.sal\n"
+        + "FROM dept\n"
+        + "JOIN emp ON emp.deptno = dept.deptno AND emp.sal < (\n"
+        + "  SELECT AVG(emp.sal)\n"
+        + "  FROM emp\n"
+        + "  WHERE  emp.deptno = dept.deptno\n"
+        + ")";
+    sql(sql)
+        .withConfig(configBuilder -> configBuilder
+            .withExpand(true)
+            .withDecorrelationEnabled(true))
+        .convertsTo("\n"
+            + "LogicalProject(DEPTNO=[$9], SAL=[$7])\n"
+            + "  LogicalJoin(condition=[AND(=($9, $0), <($7, $0))], 
joinType=[inner])\n"
+            + "    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])\n"
+            + "    LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], 
HIREDATE=[$4], "
+            + "SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[$10])\n"
+            + "      LogicalJoin(condition=[=($0, $9)], joinType=[left])\n"
+            + "        LogicalTableScan(table=[[CATALOG, SALES, EMP]])\n"
+            + "        LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])\n"

Review comment:
       Done.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to