You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2025/03/13 15:10:18 UTC

(ignite) branch master updated: IGNITE-24773 SQL Calcite: Fix missed collation for IgniteReduceSortAggregate - Fixes #11940.

This is an automated email from the ASF dual-hosted git repository.

alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new eb266bd85d4 IGNITE-24773 SQL Calcite: Fix missed collation for IgniteReduceSortAggregate - Fixes #11940.
eb266bd85d4 is described below

commit eb266bd85d455a1830ef0029c3970048187171e7
Author: Vladimir Steshin <vl...@gmail.com>
AuthorDate: Thu Mar 13 18:08:23 2025 +0300

    IGNITE-24773 SQL Calcite: Fix missed collation for IgniteReduceSortAggregate - Fixes #11940.
    
    Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
 .../calcite/rel/agg/IgniteReduceSortAggregate.java |  5 +++++
 .../integration/SortAggregateIntegrationTest.java  | 23 +++++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/agg/IgniteReduceSortAggregate.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/agg/IgniteReduceSortAggregate.java
index 83dd626e933..632df8863a4 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/agg/IgniteReduceSortAggregate.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/agg/IgniteReduceSortAggregate.java
@@ -87,6 +87,11 @@ public class IgniteReduceSortAggregate extends IgniteReduceAggregateBase impleme
         );
     }
 
+    /** {@inheritDoc} */
+    @Override public RelCollation collation() {
+        return collation;
+    }
+
     /** {@inheritDoc} */
     @Override public IgniteRel clone(RelOptCluster cluster, List<IgniteRel> inputs) {
         return new IgniteReduceSortAggregate(
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java
index 0fd9530784e..28d72a94720 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
 import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
 import org.junit.Test;
 
 /**
@@ -64,6 +65,8 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
             .addQueryField("COL0", Integer.class.getName(), null)
             .setIndexes(Collections.singletonList(new QueryIndex(fields1, QueryIndexType.SORTED)));
 
+        QueryEntity tbl12 = new QueryEntity(tbl1).setTableName("TBL12");
+
         QueryEntity part = new QueryEntity()
             .setTableName("TEST")
             .setKeyType(Integer.class.getName())
@@ -74,7 +77,8 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
             .addQueryField("GRP1", Integer.class.getName(), null)
             .addQueryField("VAL0", Integer.class.getName(), null)
             .addQueryField("VAL1", Integer.class.getName(), null)
-            .setIndexes(Collections.singletonList(new QueryIndex(Arrays.asList("GRP0", "GRP1"), QueryIndexType.SORTED)));
+            .setIndexes(F.asList(new QueryIndex(Arrays.asList("GRP0", "GRP1"), QueryIndexType.SORTED),
+                new QueryIndex(Collections.singletonList("VAL1"), QueryIndexType.SORTED)));
 
         return super.getConfiguration(igniteInstanceName)
             .setCacheConfiguration(
@@ -83,6 +87,12 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
                     .setAffinity(new RendezvousAffinityFunction(false, 8))
                     .setCacheMode(CacheMode.PARTITIONED)
                     .setQueryEntities(Arrays.asList(tbl1, part))
+                    .setSqlSchema("PUBLIC"),
+                cacheConfiguration()
+                    .setName(tbl12.getTableName())
+                    .setAffinity(new RendezvousAffinityFunction(false, 8))
+                    .setCacheMode(CacheMode.PARTITIONED)
+                    .setQueryEntities(Collections.singletonList(tbl12))
                     .setSqlSchema("PUBLIC")
             );
     }
@@ -109,6 +119,17 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
         });
     }
 
+    /** */
+    @Test
+    public void testSubqueryOtherTable() throws Exception {
+        fillCacheTbl1(client.cache("TBL12"), ROWS);
+        fillCacheTest(client.cache("TEST"), ROWS);
+
+        assertQuery("SELECT COL0 FROM TBL12 WHERE PK IN (SELECT VAL1 FROM TEST WHERE VAL0 < 2)")
+            .returns(2)
+            .check();
+    }
+
     /** */
     @Test
     public void correctCollationsOnMapReduceSortAgg() throws InterruptedException {