jinxing64 commented on a change in pull request #1468: [CALCITE-3366]
RelDecorrelator supports Union
URL: https://github.com/apache/calcite/pull/1468#discussion_r329061758
##########
File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
##########
@@ -6349,6 +6349,47 @@ private MyProjectRule(Class<? extends Project> clazz,
String planAfter = NL + RelOptUtil.toString(relAfter);
getDiffRepos().assertEquals("planAfter", "${planAfter}", planAfter);
}
+
+ @Test public void testDecorrelateUnion0() {
+ final String sql = ""
+ + "SELECT deptno FROM dept where exists\n"
+ + "(SELECT 1 FROM emp where sal < 100 and emp.deptno=dept.deptno\n"
+ + "UNION ALL\n"
+ + "SELECT 1 FROM emp where sal > 200 and emp.deptno=dept.deptno)";
+ sql(sql)
+ .withLateDecorrelation(true)
+ .withTrim(true)
+ .with(HepProgram.builder().build())
+ .check();
+ }
+
+ @Test public void testDecorrelateUnion1() {
+ // Decorrelation would fail because the input frames of Union
+ // cannot match by row schema.
+ final String sql = "SELECT * FROM emp A where (deptno, sal) in \n"
+ + "(SELECT deptno, sal FROM emp\n"
+ + "UNION ALL\n"
+ + "SELECT deptno, sal FROM emp B where A.mgr = B.empno)";
Review comment:
Yes, I should resolve the limitation.
----------------------------------------------------------------
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