This is an automated email from the ASF dual-hosted git repository.
tledkov pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push:
new 9a94b3b IGNITE-15654 Calcite engine. Fix the test
HashAggregateExecutionTest#countOfEmptyWithRewind (#9456)
9a94b3b is described below
commit 9a94b3b84fdf7ec5e57a971a4840e12d73dda90a
Author: Taras Ledkov <[email protected]>
AuthorDate: Thu Sep 30 15:50:44 2021 +0300
IGNITE-15654 Calcite engine. Fix the test
HashAggregateExecutionTest#countOfEmptyWithRewind (#9456)
---
.../exec/rel/HashAggregateExecutionTest.java | 36 +++++++++++++---------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java
index a41a776..a9e4450 100644
---
a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java
+++
b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/exec/rel/HashAggregateExecutionTest.java
@@ -73,13 +73,7 @@ public class HashAggregateExecutionTest extends
BaseAggregateTest {
agg.register(scan);
- // Collation of the first fields emulates planner behavior:
- // The group's keys placed on the begin of the output row.
- RelCollation collation = RelCollations.of(
- ImmutableIntList.copyOf(
- IntStream.range(0,
F.first(grpSets).cardinality()).boxed().collect(Collectors.toList())
- )
- );
+ RelCollation collation = createOutCollation(grpSets);
Comparator<Object[]> cmp =
ctx.expressionFactory().comparator(collation);
@@ -125,13 +119,7 @@ public class HashAggregateExecutionTest extends
BaseAggregateTest {
aggRdc.register(aggMap);
- // Collation of the first fields emulates planner behavior:
- // The group's keys placed on the begin of the output row.
- RelCollation collation = RelCollations.of(
- ImmutableIntList.copyOf(
- IntStream.range(0,
F.first(grpSets).cardinality()).boxed().collect(Collectors.toList())
- )
- );
+ RelCollation collation = createOutCollation(grpSets);
Comparator<Object[]> cmp =
ctx.expressionFactory().comparator(collation);
@@ -143,6 +131,26 @@ public class HashAggregateExecutionTest extends
BaseAggregateTest {
return sort;
}
+ /** */
+ private RelCollation createOutCollation(ImmutableList<ImmutableBitSet>
grpSets) {
+ RelCollation collation;
+
+ if (!grpSets.isEmpty() && grpSets.stream().anyMatch(set ->
!set.isEmpty())) {
+ // Sort by group to simplify compare results with expected results.
+ collation = RelCollations.of(
+ ImmutableIntList.copyOf(
+ IntStream.range(0,
F.first(grpSets).cardinality()).boxed().collect(Collectors.toList())
+ )
+ );
+ }
+ else {
+ // Sort for the first column if there are no groups.
+ collation = RelCollations.of(0);
+ }
+
+ return collation;
+ }
+
/**
* Test verifies that after rewind all groups are properly initialized.
*/