jamesstarr commented on a change in pull request #2571:
URL: https://github.com/apache/calcite/pull/2571#discussion_r725244082
##########
File path:
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java
##########
@@ -168,6 +168,62 @@
"empid=200");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-4833">[CALCITE-4833]
+ * Complex nested correlated subquery failed</a>.
+ */
+ @Test void complexNestedCorrelatedSubquery() {
Review comment:
Could you split this up into multiple tests.
##########
File path:
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java
##########
@@ -168,6 +168,62 @@
"empid=200");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-4833">[CALCITE-4833]
+ * Complex nested correlated subquery failed</a>.
+ */
+ @Test void complexNestedCorrelatedSubquery() {
+ String sql = "SELECT t1.empid FROM emps t1 LEFT JOIN emps t2 ON (SELECT
t2.empid)<=101";
Review comment:
Could you please rework to join on different tables.
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -4974,6 +5008,16 @@ void registerSubQuery(SqlNode node, RelOptUtil.Logic
logic) {
final SqlNode query;
final RelRoot root;
switch (kind) {
+ case LESS_THAN:
+ case GREATER_THAN:
+ case LESS_THAN_OR_EQUAL:
+ case GREATER_THAN_OR_EQUAL:
+ case EQUALS:
+ RexNode res = simplifyOnWithSelectInConditions(expr);
+ if (res != null) {
Review comment:
On the non expand path, we should be translating this RexSubquery, not
doing a simplification of a trivial query.
##########
File path:
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java
##########
@@ -168,6 +168,62 @@
"empid=200");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-4833">[CALCITE-4833]
+ * Complex nested correlated subquery failed</a>.
+ */
+ @Test void complexNestedCorrelatedSubquery() {
+ String sql = "SELECT t1.empid FROM emps t1 LEFT JOIN emps t2 ON (SELECT
t2.empid)<=101";
+
+ tester(false, new HrSchema())
+ .query(sql)
+ .returnsUnordered(
Review comment:
Please add explainContains.
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -4974,6 +5008,16 @@ void registerSubQuery(SqlNode node, RelOptUtil.Logic
logic) {
final SqlNode query;
final RelRoot root;
switch (kind) {
+ case LESS_THAN:
+ case GREATER_THAN:
+ case LESS_THAN_OR_EQUAL:
+ case GREATER_THAN_OR_EQUAL:
+ case EQUALS:
+ RexNode res = simplifyOnWithSelectInConditions(expr);
+ if (res != null) {
+ return res;
+ }
+ break;
Review comment:
We should throw an unsupported operation here.
--
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]