Skip to content

Commit eb266bd

Browse files
Vladsz83alex-plekhanov
authored andcommitted
IGNITE-24773 SQL Calcite: Fix missed collation for IgniteReduceSortAggregate - Fixes #11940.
Signed-off-by: Aleksey Plekhanov <plehanov.alex@gmail.com>
1 parent 921d41e commit eb266bd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/agg/IgniteReduceSortAggregate.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public IgniteReduceSortAggregate(RelInput input) {
8787
);
8888
}
8989

90+
/** {@inheritDoc} */
91+
@Override public RelCollation collation() {
92+
return collation;
93+
}
94+
9095
/** {@inheritDoc} */
9196
@Override public IgniteRel clone(RelOptCluster cluster, List<IgniteRel> inputs) {
9297
return new IgniteReduceSortAggregate(

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SortAggregateIntegrationTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.ignite.cache.QueryIndexType;
2929
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
3030
import org.apache.ignite.configuration.IgniteConfiguration;
31+
import org.apache.ignite.internal.util.typedef.F;
3132
import org.junit.Test;
3233

3334
/**
@@ -64,6 +65,8 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
6465
.addQueryField("COL0", Integer.class.getName(), null)
6566
.setIndexes(Collections.singletonList(new QueryIndex(fields1, QueryIndexType.SORTED)));
6667

68+
QueryEntity tbl12 = new QueryEntity(tbl1).setTableName("TBL12");
69+
6770
QueryEntity part = new QueryEntity()
6871
.setTableName("TEST")
6972
.setKeyType(Integer.class.getName())
@@ -74,7 +77,8 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
7477
.addQueryField("GRP1", Integer.class.getName(), null)
7578
.addQueryField("VAL0", Integer.class.getName(), null)
7679
.addQueryField("VAL1", Integer.class.getName(), null)
77-
.setIndexes(Collections.singletonList(new QueryIndex(Arrays.asList("GRP0", "GRP1"), QueryIndexType.SORTED)));
80+
.setIndexes(F.asList(new QueryIndex(Arrays.asList("GRP0", "GRP1"), QueryIndexType.SORTED),
81+
new QueryIndex(Collections.singletonList("VAL1"), QueryIndexType.SORTED)));
7882

7983
return super.getConfiguration(igniteInstanceName)
8084
.setCacheConfiguration(
@@ -83,6 +87,12 @@ public class SortAggregateIntegrationTest extends AbstractBasicIntegrationTransa
8387
.setAffinity(new RendezvousAffinityFunction(false, 8))
8488
.setCacheMode(CacheMode.PARTITIONED)
8589
.setQueryEntities(Arrays.asList(tbl1, part))
90+
.setSqlSchema("PUBLIC"),
91+
cacheConfiguration()
92+
.setName(tbl12.getTableName())
93+
.setAffinity(new RendezvousAffinityFunction(false, 8))
94+
.setCacheMode(CacheMode.PARTITIONED)
95+
.setQueryEntities(Collections.singletonList(tbl12))
8696
.setSqlSchema("PUBLIC")
8797
);
8898
}
@@ -109,6 +119,17 @@ public void mapReduceAggregate() throws InterruptedException {
109119
});
110120
}
111121

122+
/** */
123+
@Test
124+
public void testSubqueryOtherTable() throws Exception {
125+
fillCacheTbl1(client.cache("TBL12"), ROWS);
126+
fillCacheTest(client.cache("TEST"), ROWS);
127+
128+
assertQuery("SELECT COL0 FROM TBL12 WHERE PK IN (SELECT VAL1 FROM TEST WHERE VAL0 < 2)")
129+
.returns(2)
130+
.check();
131+
}
132+
112133
/** */
113134
@Test
114135
public void correctCollationsOnMapReduceSortAgg() throws InterruptedException {

0 commit comments

Comments
 (0)