hsyuan commented on a change in pull request #1466: [CALCITE-3363]
JoinUnionTransposeRule.RIGHT_UNION should not match ANTI join
URL: https://github.com/apache/calcite/pull/1466#discussion_r326451861
##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -1778,6 +1778,53 @@ private void
basePushFilterPastAggWithGroupingSets(boolean unchanged)
+ "(select * from emp e1 union all select * from emp e2) r2");
}
+ @Test public void testPushJoinThroughUnionOnRightDoesNotMatchAntiJoin() {
+ final RelBuilder builder =
RelBuilder.create(RelBuilderTest.config().build());
+
+ // build a rel equivalent to sql:
+ // select r1.sal from
+ // emp r1 where r1.deptno not in
+ // (select deptno from dept d1 where deptno < 10
+ // union all
+ // select deptno from dept d2 where deptno > 20)
+ RelNode left = builder.scan("EMP").build();
+ RelNode right = builder
+ .scan("DEPT")
+ .filter(
+ builder.call(SqlStdOperatorTable.LESS_THAN,
+ builder.field("DEPTNO"),
+ builder.literal(10)))
+ .project(builder.field("DEPTNO"))
+ .scan("DEPT")
+ .filter(
+ builder.call(SqlStdOperatorTable.GREATER_THAN,
+ builder.field("DEPTNO"),
+ builder.literal(20)))
+ .project(builder.field("DEPTNO"))
+ .union(true)
+ .build();
+ RelNode relNode = builder.push(left).push(right)
+ .antiJoin(
+ builder.call(SqlStdOperatorTable.EQUALS,
+ builder.field(2, 0, "DEPTNO"),
+ builder.field(2, 1, "DEPTNO")))
+ .project(builder.field("SAL"))
+ .build();
Review comment:
Is it possible to write SQL directly?
----------------------------------------------------------------
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