herunkang2018 commented on code in PR #3182:
URL: https://github.com/apache/calcite/pull/3182#discussion_r1181152549
##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -6448,6 +6448,42 @@ private void checkSemiJoinRuleOnAntiJoin(RelOptRule
rule) {
.check();
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5680">[CALCITE-5680]
+ * Wrong field reference lookup due to same intermediate table alias
+ * of multiple sub-queries with only literal operands in subquery remove
phase</a>. */
+ @Test void testExpandFilterConstantInCorrelatedWithTwoSubQueries() {
+ final String sql = "select empno from sales.empnullables as e\n"
+ + "where 1 in (\n"
+ + " select deptno from sales.deptnullables where e.ename = name and
deptno > 10)\n"
+ + "or 2 in (\n"
+ + " select deptno from sales.deptnullables where e.ename = name and
deptno < 20)";
+ System.out.println(sql);
+ sql(sql)
+ .withSubQueryRules()
+ .withRelBuilderSimplify(false)
+ .withTrim(true)
+ .check();
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5680">[CALCITE-5680]
+ * Wrong field reference lookup due to same intermediate table alias
+ * of multiple sub-queries with only literal operands in subquery remove
phase</a>. */
+ @Test void testExpandFilterConstantInWithTwoSubQueries() {
+ final String sql = "select empno from sales.empnullables\n"
+ + "where 1 in (\n"
+ + " select deptno from sales.deptnullables where name = 'dept1')\n"
+ + "or 2 in (\n"
+ + " select deptno from sales.deptnullables where name = 'dept2')";
+ System.out.println(sql);
+ sql(sql)
+ .withSubQueryRules()
+ .withRelBuilderSimplify(false)
Review Comment:
Thanks for your suggestion, I will add it soon.
--
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]