NobiGo commented on code in PR #4244:
URL: https://github.com/apache/calcite/pull/4244#discussion_r2026275279
##########
core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml:
##########
@@ -5980,6 +5980,64 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], T=[$10])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4],
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f9=[7934],
$f10=[CURRENT_TIMESTAMP])
LogicalFilter(condition=[=($0, 7934)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testIntersectReorderRule">
+ <Resource name="sql">
+ <![CDATA[select deptno from emp
+intersect
+select deptno from emp where deptno > 5
+]]>
+ </Resource>
+ <Resource name="planBefore">
+ <![CDATA[
+LogicalIntersect(all=[false])
+ LogicalProject(DEPTNO=[$7])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalProject(DEPTNO=[$7])
+ LogicalFilter(condition=[>($7, 5)])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+ </Resource>
+ <Resource name="planAfter">
+ <![CDATA[
+EnumerableIntersect(all=[false])
Review Comment:
These are all test cases for intersect. we can also cover the case of
`intersect all`.
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -10059,4 +10059,35 @@ private void
checkLoptOptimizeJoinRule(LoptOptimizeJoinRule rule) {
sql(sql).withRule(CoreRules.INTERSECT_TO_EXISTS)
.checkUnchanged();
}
+
+ /** Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-6891">[CALCITE-6891]
+ * Implement IntersectReorderRule</a>. */
+ @Test void testIntersectReorderRule() {
+ final String sql = "select deptno from emp\n"
+ + "intersect\n"
+ + "select deptno from emp where deptno > 5\n";
+
+ sql(sql).withVolcanoPlanner(true, p -> {
+ p.addRule(CoreRules.INTERSECT_REORDER);
+ p.addRule(EnumerableRules.ENUMERABLE_TABLE_SCAN_RULE);
+ p.addRule(EnumerableRules.ENUMERABLE_INTERSECT_RULE);
+ p.addRule(EnumerableRules.ENUMERABLE_FILTER_RULE);
+ p.addRule(EnumerableRules.ENUMERABLE_PROJECT_RULE);
+ }).check();
+ }
+
+ /** Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-6891">
Review Comment:
The style of the javadoc needs to be consistent with that of others.
--
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]