hsyuan commented on a change in pull request #1169: [CALCITE-2948] 
SqlToRelConverter generates complicated logical plan f…
URL: https://github.com/apache/calcite/pull/1169#discussion_r279214148
 
 

 ##########
 File path: 
core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
 ##########
 @@ -3321,6 +3321,97 @@ LogicalProject(DEPTNO=[$7])
       LogicalSort(sort0=[$0], dir0=[ASC], fetch=[1])
         LogicalProject(DEPTNO=[$7])
           LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInSubqueryWithNonEqualCondition">
+        <Resource name="sql">
+            <![CDATA[select deptno
+from EMP e
+where deptno in (select deptno
+from EMP where empno=e.empno+1)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+    LogicalAggregate(group=[{0, 1}])
+      LogicalProject(DEPTNO=[$7], $f9=[-($0, 1)])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInSubqueryWithNonEqualCondition1">
+        <Resource name="sql">
+            <![CDATA[select deptno
+from EMP e
+where deptno in (select deptno
+from EMP where empno=1+e.empno)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+    LogicalAggregate(group=[{0, 1}])
+      LogicalProject(DEPTNO=[$7], $f9=[-($0, 1)])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInSubqueryWithNonEqualCondition2">
+        <Resource name="sql">
+            <![CDATA[select deptno
+from EMP e
+where deptno in (select deptno
+from EMP where empno=e.empno-1)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+    LogicalAggregate(group=[{0, 1}])
+      LogicalProject(DEPTNO=[$7], $f9=[+($0, 1)])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInSubqueryWithNonEqualCondition3">
+        <Resource name="sql">
+            <![CDATA[select deptno
+from EMP e
+where deptno in (select deptno
+from EMP where empno=1-e.empno)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalJoin(condition=[AND(=($0, $10), =($7, $9))], joinType=[inner])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+    LogicalAggregate(group=[{0, 1}])
+      LogicalProject(DEPTNO=[$7], $f9=[-(1, $0)])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInSubqueryWithNonEqualCondition4">
+        <Resource name="sql">
+            <![CDATA[select deptno
+from dept d
+where deptno in (select deptno
+from EMP where empno=d.deptno+1)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$0])
+  LogicalJoin(condition=[=($0, $3)], joinType=[inner])
+    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+    LogicalFilter(condition=[=($1, $0)])
+      LogicalAggregate(group=[{0, 1}])
+        LogicalProject(DEPTNO=[$7], $f9=[-($0, 1)])
+          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 
 Review comment:
   This plan is incorrect. 

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


With regards,
Apache Git Services

Reply via email to