alex-plekhanov commented on a change in pull request #9593:
URL: https://github.com/apache/ignite/pull/9593#discussion_r756055705



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/LogicalScanConverterRule.java
##########
@@ -81,6 +81,12 @@
                     .replace(collation);
 
                 Set<CorrelationId> corrIds = 
RexUtils.extractCorrelationIds(rel.condition());
+
+                if (!F.isEmpty(rel.projects())) {

Review comment:
       Why only for index scan? Table scan should be fixed too.

##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
##########
@@ -1148,6 +1150,22 @@ public void testSelectWithOrdering() throws 
IgniteInterruptedCheckedException {
             .check();
     }
 
+    /**
+     * Checks exchnage-before-correlate and correct multy-value subquery error.
+     */
+    @Test
+    public void testSubqueryMultyValueError() throws 
IgniteInterruptedCheckedException {
+        sql("create table test_tbl(v INTEGER)", true);
+
+        sql("INSERT INTO test_tbl VALUES (1), (2), (3), (4), (5)", true);
+
+        Throwable err = GridTestUtils.assertThrows(log,
+            () -> sql("SELECT t0.v, (SELECT t0.v + t1.v FROM test_tbl t1) AS j 
FROM test_tbl t0"),
+            IgniteSQLException.class, null);
+
+        assertTrue(X.hasCause(err, "Subquery returned more than 1 value", 
IllegalArgumentException.class));

Review comment:
       Can we write a query that is not throwing an exception after a fix, but 
throwing an exception without fix? For example by reducing the number of rows 
in test_tbl? If not, perhaps we should write planner test.

##########
File path: 
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
##########
@@ -1148,6 +1150,22 @@ public void testSelectWithOrdering() throws 
IgniteInterruptedCheckedException {
             .check();
     }
 
+    /**
+     * Checks exchnage-before-correlate and correct multy-value subquery error.
+     */
+    @Test
+    public void testSubqueryMultyValueError() throws 
IgniteInterruptedCheckedException {

Review comment:
       The test name doesn't match javadoc. 
   Actually, we should check correlated queries with correlates in projects 
(without correlates in filters), perhaps we should name the test (and fix the 
javadoc) according to this check. 
   Also, fix typos (`multy` -> `multi`, `exchnage` -> `exchange`)




-- 
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]


Reply via email to