This is an automated email from the ASF dual-hosted git repository.
mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new fa502eda26 [CALCITE-6960] The tests for SemiJoinRemoveRule should
explicitly include a semi join
fa502eda26 is described below
commit fa502eda26f28b1a030c94a26c736d06d67cf33e
Author: Zhen Chen <[email protected]>
AuthorDate: Tue Apr 15 22:17:27 2025 +0800
[CALCITE-6960] The tests for SemiJoinRemoveRule should explicitly include a
semi join
---
.../org/apache/calcite/test/RelOptRulesTest.java | 24 ++++++-------
.../org/apache/calcite/test/RelOptRulesTest.xml | 41 ++++++++++++++--------
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index 47db4459fd..9ccd441bad 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -4257,9 +4257,9 @@ private void
checkPushJoinThroughUnionOnRightDoesNotMatchSemiOrAntiJoin(JoinRelT
final String sql = "select e.ename from emp e, dept d\n"
+ "where e.deptno = d.deptno";
sql(sql)
- .withRule(CoreRules.FILTER_INTO_JOIN,
- CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN,
- CoreRules.SEMI_JOIN_REMOVE)
+ .withPreRule(CoreRules.FILTER_INTO_JOIN,
+ CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN)
+ .withRule(CoreRules.SEMI_JOIN_REMOVE)
.check();
}
@@ -4267,10 +4267,10 @@ private void
checkPushJoinThroughUnionOnRightDoesNotMatchSemiOrAntiJoin(JoinRelT
final String sql = "select e.ename from emp e, dept d\n"
+ "where e.deptno = d.deptno and e.ename = 'foo'";
sql(sql)
- .withRule(CoreRules.FILTER_INTO_JOIN,
+ .withPreRule(CoreRules.FILTER_INTO_JOIN,
CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN,
- CoreRules.SEMI_JOIN_FILTER_TRANSPOSE,
- CoreRules.SEMI_JOIN_REMOVE)
+ CoreRules.SEMI_JOIN_FILTER_TRANSPOSE)
+ .withRule(CoreRules.SEMI_JOIN_REMOVE)
.check();
}
@@ -4278,10 +4278,10 @@ private void
checkPushJoinThroughUnionOnRightDoesNotMatchSemiOrAntiJoin(JoinRelT
final String sql = "select e1.ename from emp e1, dept d, emp e2\n"
+ "where e1.deptno = d.deptno and d.deptno = e2.deptno";
sql(sql)
- .withRule(CoreRules.FILTER_INTO_JOIN,
+ .withPreRule(CoreRules.FILTER_INTO_JOIN,
CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN,
- CoreRules.SEMI_JOIN_JOIN_TRANSPOSE,
- CoreRules.SEMI_JOIN_REMOVE)
+ CoreRules.SEMI_JOIN_JOIN_TRANSPOSE)
+ .withRule(CoreRules.SEMI_JOIN_REMOVE)
.check();
}
@@ -4290,11 +4290,11 @@ private void
checkPushJoinThroughUnionOnRightDoesNotMatchSemiOrAntiJoin(JoinRelT
+ "where e1.deptno = d.deptno and d.deptno = e2.deptno\n"
+ "and d.name = 'foo'";
sql(sql)
- .withRule(CoreRules.FILTER_INTO_JOIN,
+ .withPreRule(CoreRules.FILTER_INTO_JOIN,
CoreRules.JOIN_ADD_REDUNDANT_SEMI_JOIN,
CoreRules.SEMI_JOIN_JOIN_TRANSPOSE,
- CoreRules.SEMI_JOIN_FILTER_TRANSPOSE,
- CoreRules.SEMI_JOIN_REMOVE)
+ CoreRules.SEMI_JOIN_FILTER_TRANSPOSE)
+ .withRule(CoreRules.SEMI_JOIN_REMOVE)
.check();
}
diff --git
a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
index 4ff87b444e..bf70b7878d 100644
--- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
@@ -15232,10 +15232,11 @@ where e.deptno = d.deptno]]>
<Resource name="planBefore">
<![CDATA[
LogicalProject(ENAME=[$1])
- LogicalFilter(condition=[=($7, $9)])
- LogicalJoin(condition=[true], joinType=[inner])
+ LogicalJoin(condition=[=($7, $9)], joinType=[inner], semiJoinDone=[true])
+ LogicalJoin(condition=[=($7, $9)], joinType=[semi])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="planAfter">
@@ -15255,12 +15256,15 @@ where e1.deptno = d.deptno and d.deptno = e2.deptno]]>
<Resource name="planBefore">
<![CDATA[
LogicalProject(ENAME=[$1])
- LogicalFilter(condition=[AND(=($7, $9), =($9, $18))])
- LogicalJoin(condition=[true], joinType=[inner])
- LogicalJoin(condition=[true], joinType=[inner])
+ LogicalJoin(condition=[=($9, $18)], joinType=[inner], semiJoinDone=[true])
+ LogicalJoin(condition=[=($7, $9)], joinType=[inner], semiJoinDone=[true])
+ LogicalJoin(condition=[=($7, $9)], joinType=[semi])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
- LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalJoin(condition=[=($0, $9)], joinType=[semi])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planAfter">
@@ -15283,12 +15287,17 @@ and d.name = 'foo']]>
<Resource name="planBefore">
<![CDATA[
LogicalProject(ENAME=[$1])
- LogicalFilter(condition=[AND(=($7, $9), =($9, $18), =($10, 'foo'))])
- LogicalJoin(condition=[true], joinType=[inner])
- LogicalJoin(condition=[true], joinType=[inner])
+ LogicalJoin(condition=[=($9, $18)], joinType=[inner], semiJoinDone=[true])
+ LogicalJoin(condition=[=($7, $9)], joinType=[inner], semiJoinDone=[true])
+ LogicalJoin(condition=[=($7, $9)], joinType=[semi])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
- LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
- LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalFilter(condition=[=($1, 'foo')])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalFilter(condition=[=($1, 'foo')])
+ LogicalJoin(condition=[=($0, $9)], joinType=[semi])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planAfter">
@@ -15311,10 +15320,12 @@ where e.deptno = d.deptno and e.ename = 'foo']]>
<Resource name="planBefore">
<![CDATA[
LogicalProject(ENAME=[$1])
- LogicalFilter(condition=[AND(=($7, $9), =($1, 'foo'))])
- LogicalJoin(condition=[true], joinType=[inner])
- LogicalTableScan(table=[[CATALOG, SALES, EMP]])
- LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalJoin(condition=[=($7, $9)], joinType=[inner], semiJoinDone=[true])
+ LogicalFilter(condition=[=($1, 'foo')])
+ LogicalJoin(condition=[=($7, $9)], joinType=[semi])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+ LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="planAfter">