You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/03/21 03:09:53 UTC

[GitHub] [calcite] chunweilei commented on a change in pull request #1121: [CALCITE-2936] Simplify EXISTS or NOT EXISTS sub-query that has "GROUP BY ()"

chunweilei commented on a change in pull request #1121: [CALCITE-2936] Simplify EXISTS or NOT EXISTS sub-query that has "GROUP BY ()"
URL: https://github.com/apache/calcite/pull/1121#discussion_r267615145
 
 

 ##########
 File path: core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
 ##########
 @@ -3150,6 +3150,60 @@ group by deptno]]>
 LogicalAggregate(group=[{0}], EXPR$1=[SUM($1) FILTER $2], EXPR$2=[COUNT()])
   LogicalProject(DEPTNO=[$7], $f1=[*($5, 2)], $f2=[AND(<>($0, 1), <>($0, 2))])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSimplifyExistsAggregateSubQuery">
+        <Resource name="sql">
+            <![CDATA[SELECT e1.empno
+        FROM emp e1 where exists
+        (select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(EMPNO=[$0])
+  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSimplifyNotExistsAggregateSubQuery">
+        <Resource name="sql">
+            <![CDATA[SELECT e1.empno
+        FROM emp e1 where not exists
+        (select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(EMPNO=[$0])
+  LogicalFilter(condition=[NOT(true)])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSimplifyExistsValuesSubQuery">
+        <Resource name="sql">
+            <![CDATA[select deptno
+        from EMP
+        where exists (values 10)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testSimplifyNotExistsValuesSubQuery">
+        <Resource name="sql">
+            <![CDATA[select deptno
+        from EMP
+        where not exists (values 10)]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalProject(DEPTNO=[$7])
+  LogicalFilter(condition=[NOT(true)])
+    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 
 Review comment:
   Why is it `NOT(true)` rather than `false`?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services