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

amashenkov pushed a commit to branch ignite-21580
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 04540a545e309d2db1a8c3c6716c2bf99082ae22
Author: amashenkov <[email protected]>
AuthorDate: Wed Mar 27 17:13:55 2024 +0300

    Fix tests.
---
 .../sql/engine/planner/AggregatePlannerTest.java   | 237 ++++++++++-----------
 .../planner/ColocatedHashAggregatePlannerTest.java |  18 +-
 .../planner/MapReduceHashAggregatePlannerTest.java |  92 ++++----
 .../planner/MapReduceSortAggregatePlannerTest.java |  28 +--
 4 files changed, 189 insertions(+), 186 deletions(-)

diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AggregatePlannerTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AggregatePlannerTest.java
index d2b0e8a423..1c6cdd2547 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AggregatePlannerTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AggregatePlannerTest.java
@@ -31,6 +31,7 @@ import 
org.apache.ignite.internal.sql.engine.rel.IgniteCorrelatedNestedLoopJoin;
 import org.apache.ignite.internal.sql.engine.rel.IgniteExchange;
 import org.apache.ignite.internal.sql.engine.rel.IgniteLimit;
 import org.apache.ignite.internal.sql.engine.rel.IgniteMergeJoin;
+import org.apache.ignite.internal.sql.engine.rel.IgniteProject;
 import org.apache.ignite.internal.sql.engine.rel.IgniteSort;
 import org.apache.ignite.internal.sql.engine.rel.IgniteTableScan;
 import 
org.apache.ignite.internal.sql.engine.rel.agg.IgniteColocatedHashAggregate;
@@ -40,6 +41,7 @@ import 
org.apache.ignite.internal.sql.engine.rel.agg.IgniteMapSortAggregate;
 import org.apache.ignite.internal.sql.engine.rel.agg.IgniteReduceHashAggregate;
 import org.apache.ignite.internal.sql.engine.rel.agg.IgniteReduceSortAggregate;
 import org.apache.ignite.internal.sql.engine.schema.IgniteIndex.Collation;
+import org.apache.ignite.internal.sql.engine.trait.IgniteDistributions;
 import org.apache.ignite.internal.sql.engine.trait.TraitUtils;
 import org.junit.jupiter.api.Test;
 
@@ -118,9 +120,8 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
         checkSimpleAggWithGroupByHash(TestCase.CASE_5A);
         checkSimpleAggWithGroupByHash(TestCase.CASE_5B);
 
-        // TODO replace with calls to test methods after 
https://issues.apache.org/jira/browse/IGNITE-20083 is resolved
-        assumeRun("checkSimpleAggWithGroupByHash", TestCase.CASE_6A);
-        assumeRun("checkSimpleAggWithGroupByHash", TestCase.CASE_6B);
+        checkSimpleAggWithGroupByHash(TestCase.CASE_6A);
+        checkSimpleAggWithGroupByHash(TestCase.CASE_6B);
 
         checkSimpleAggWithColocatedGroupByHash(TestCase.CASE_5C);
         checkSimpleAggWithColocatedGroupByHash(TestCase.CASE_5D);
@@ -250,22 +251,8 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
     public void distinctAggregateInWhereClause() throws Exception {
         checkGroupWithNoAggregateSingle(TestCase.CASE_15);
 
-        assertPlan(TestCase.CASE_15A,
-                nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
-                        .and(not(hasAggregate()))
-                        .and(hasGroups())
-                        .and(input(isInstanceOf(IgniteExchange.class)
-                                .and(input(isTableScan("TEST")))
-                        ))
-                ));
-        assertPlan(TestCase.CASE_15B,
-                nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
-                        .and(not(hasAggregate()))
-                        .and(hasGroups())
-                        .and(input(isInstanceOf(IgniteExchange.class)
-                                .and(input(isTableScan("TEST")))
-                        ))
-                ));
+        checkGroupWithNoAggregateHash(TestCase.CASE_15A);
+        checkGroupWithNoAggregateHash(TestCase.CASE_15B);
     }
 
     /**
@@ -367,14 +354,14 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
      */
     @Test
     public void aggregateWithOrderByGroupColumns() throws Exception {
-        checkGroupsWithOrderByGroupColumnsSingle(TestCase.CASE_19_1, 
TraitUtils.createCollation(List.of(0, 1)));
-        checkGroupsWithOrderByGroupColumnsSingle(TestCase.CASE_19_2, 
TraitUtils.createCollation(List.of(1, 0)));
+        checkGroupsWithOrderByGroupColumnsSingle(TestCase.CASE_19_1, 
TraitUtils.createCollation(List.of(0)));
+        checkGroupsWithOrderByGroupColumnsSingle(TestCase.CASE_19_2, 
TraitUtils.createCollation(List.of(1)));
 
-        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_1A, 
TraitUtils.createCollation(List.of(0, 1)));
-        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_2A, 
TraitUtils.createCollation(List.of(1, 0)));
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_1A, 
TraitUtils.createCollation(List.of(0)));
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_2A, 
TraitUtils.createCollation(List.of(1)));
 
-        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_1B, 
TraitUtils.createCollation(List.of(0, 1)));
-        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_2B, 
TraitUtils.createCollation(List.of(1, 0)));
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_1B, 
TraitUtils.createCollation(List.of(0)));
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_19_2B, 
TraitUtils.createCollation(List.of(1)));
     }
 
     /**
@@ -382,32 +369,10 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
      */
     @Test
     public void aggregateWithGroupBySubsetOrderByColumns() throws Exception {
-        assertPlan(TestCase.CASE_20,
-                isInstanceOf(IgniteSort.class)
-                        .and(s -> 
s.collation().equals(TraitUtils.createCollation(List.of(0, 1, 2))))
-                        
.and(nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(input(isTableScan("TEST")))
-                        ))
-        );
+        checkGroupsWithOrderByGroupColumnsSingle(TestCase.CASE_20, 
TraitUtils.createCollation(List.of(0, 1, 2)));
 
-        assertPlan(TestCase.CASE_20A,
-                isInstanceOf(IgniteSort.class)
-                        .and(s -> 
s.collation().equals(TraitUtils.createCollation(List.of(0, 1, 2))))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(input(isInstanceOf(IgniteExchange.class)
-                                        .and(input(isTableScan("TEST")))
-                                ))
-                        ))
-        );
-        assertPlan(TestCase.CASE_20B,
-                isInstanceOf(IgniteSort.class)
-                        .and(s -> 
s.collation().equals(TraitUtils.createCollation(List.of(0, 1, 2))))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(input(isInstanceOf(IgniteExchange.class)
-                                        .and(input(isTableScan("TEST")))
-                                ))
-                        ))
-        );
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_20A, 
TraitUtils.createCollation(List.of(0, 1, 2)));
+        checkGroupsWithOrderByGroupColumnsHash(TestCase.CASE_20B, 
TraitUtils.createCollation(List.of(0, 1, 2)));
     }
 
 
@@ -470,7 +435,7 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
         Predicate<AggregateCall> countReduce = (a) ->
                 Objects.equals(a.getAggregation().getName(), "$SUM0") && 
a.getArgList().equals(List.of(1));
 
-        Predicate<RelNode> nonColocatedGroupBy = 
hasChildThat(isInstanceOf(IgniteReduceHashAggregate.class)
+        Predicate<RelNode> nonColocatedGroupBy = 
nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class)
                 .and(in -> 
hasAggregates(countReduce).test(in.getAggregateCalls()))
                 .and(input(isInstanceOf(IgniteExchange.class)
                         .and(input(isInstanceOf(IgniteMapHashAggregate.class)
@@ -497,17 +462,37 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
     /** Validate that we choose single phase AVG aggregate for AVG by default. 
*/
     @Test
     public void avgAgg() throws Exception {
-        Predicate<AggregateCall> countMap = (a) -> 
Objects.equals(a.getAggregation().getName(), "AVG") && 
a.getArgList().equals(List.of(1));
+        Predicate<AggregateCall> colocated = (a) ->
+                Objects.equals(a.getAggregation().getName(), "AVG") && 
a.getArgList().equals(List.of(1));
 
-        Predicate<IgniteColocatedHashAggregate> nonColocated = 
isInstanceOf(IgniteColocatedHashAggregate.class)
-                .and(in -> hasAggregates(countMap).test(in.getAggCallList()))
-                .and(input(isInstanceOf(IgniteExchange.class)
-                        .and(hasDistribution(single()))));
+        Predicate<AggregateCall> sumMap = (a) ->
+                Objects.equals(a.getAggregation().getName(), "SUM") && 
a.getArgList().equals(List.of(1));
+
+        Predicate<AggregateCall> countMap = (a) ->
+                Objects.equals(a.getAggregation().getName(), "COUNT") && 
a.getArgList().equals(List.of(1));
+
+        Predicate<AggregateCall> sumReduce = (a) ->
+                Objects.equals(a.getAggregation().getName(), "SUM") && 
a.getArgList().equals(List.of(1));
+
+        Predicate<AggregateCall> sum0Reduce = (a) ->
+                Objects.equals(a.getAggregation().getName(), "$SUM0") && 
a.getArgList().equals(List.of(2));
+
+        Predicate<RelNode> nonColocated = 
hasChildThat(isInstanceOf(IgniteReduceHashAggregate.class)
+                .and(in -> hasAggregates(sumReduce, 
sum0Reduce).test(in.getAggregateCalls()))
+                .and(input(isInstanceOf(IgniteProject.class)
+                        .and(input(isInstanceOf(IgniteExchange.class)
+                                .and(hasDistribution(single()))
+                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                                .and(in -> 
hasAggregates(sumMap, countMap).test(in.getAggCallList()))
+                                        )
+                                ))
+                        ))));
 
         Predicate<IgniteExchange> colocatedGroupBy = 
isInstanceOf(IgniteExchange.class)
                 .and(hasDistribution(single()))
                 .and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                        .and(in -> 
hasAggregates(countMap).test(in.getAggCallList()))
+                        .and(in -> 
hasAggregates(colocated).test(in.getAggCallList()))
+                        .and(hasGroups())
                         .and(input(isTableScan("TEST")))
                 ));
 
@@ -538,20 +523,15 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
         checkCountDistinctHash(TestCase.CASE_24_1B);
         checkCountDistinctHash(TestCase.CASE_24_1D);
 
-        Predicate<RelNode> colocated = 
nodeOrAnyChild(isInstanceOf(IgniteReduceSortAggregate.class)
-                .and(hasNoGroupSets(IgniteReduceSortAggregate::getGroupSets))
+        Predicate<RelNode> colocated = 
nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class)
+                
.and(hasNoGroupSets(IgniteColocatedSortAggregate::getGroupSets))
                 .and(input(isInstanceOf(IgniteExchange.class)
                         .and(hasDistribution(single())
-                                
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                        
.and(hasNoGroupSets(IgniteMapSortAggregate::getGroupSets))
-                                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                                
.and(hasGroupSets(IgniteColocatedHashAggregate::getGroupSets, 1))
-                                        ))
+                                
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
+                                        
.and(hasGroupSets(IgniteColocatedHashAggregate::getGroupSets, 1))
                                 ))
-                        )
-                ))
-
-        );
+                        ))
+                ));
 
         assertPlan(TestCase.CASE_24_1C, colocated);
         assertPlan(TestCase.CASE_24_1E, colocated);
@@ -640,39 +620,39 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
         assertPlan(testCase,
                 isInstanceOf(IgniteColocatedHashAggregate.class)
                         .and(hasAggregate())
-                        .and(not(hasDistinctAggregate()))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(hasGroups())
-                                .and(input(isTableScan("TEST")))
-                        ))
+                        .and(hasDistinctAggregate())
+                        .and(hasGroups())
+                        .and(input(isTableScan("TEST")))
         );
     }
 
     private void checkDistinctAggHash(TestCase testCase) throws Exception {
         assertPlan(testCase,
-                isInstanceOf(IgniteColocatedHashAggregate.class)
+                nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
                         .and(hasAggregate())
                         .and(not(hasDistinctAggregate()))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
+                        
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
+                                .and(not(hasAggregate()))
                                 .and(hasGroups())
                                 .and(input(isInstanceOf(IgniteExchange.class)
-                                        .and(input(isTableScan("TEST")))
+                                        
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                                .and(not(hasAggregate()))
+                                                
.and(input(isTableScan("TEST")))
+                                        ))
                                 ))
                         ))
-        );
+                ));
     }
 
     private void checkColocatedDistinctAggHash(TestCase testCase) throws 
Exception {
         assertPlan(testCase,
-                nodeOrAnyChild(isInstanceOf(IgniteReduceSortAggregate.class)
+                nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class)
+                        .and(hasAggregate())
+                        .and(not(hasDistinctAggregate()))
                         .and(input(isInstanceOf(IgniteExchange.class)
-                                
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                        .and(hasAggregate())
-                                        .and(not(hasDistinctAggregate()))
-                                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                                .and(hasGroups())
-                                                
.and(input(isTableScan("TEST")))
-                                        ))
+                                
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
+                                        .and(hasGroups())
+                                        .and(input(isTableScan("TEST")))
                                 ))
                         ))
                 ));
@@ -688,16 +668,25 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
         );
     }
 
+
     private void checkDistinctAggWithGroupByHash(TestCase testCase) throws 
Exception {
         assertPlan(testCase,
                 nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
-                        .and(hasDistinctAggregate())
+                        .and(hasAggregate())
+                        .and(not(hasDistinctAggregate()))
                         .and(hasGroups())
-                        .and(input(isInstanceOf(IgniteExchange.class)
-                                .and(input(isTableScan("TEST")))
+                        
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
+                                .and(not(hasAggregate()))
+                                .and(hasGroups())
+                                .and(input(isInstanceOf(IgniteExchange.class)
+                                        
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                                .and(not(hasAggregate()))
+                                                .and(hasGroups())
+                                                
.and(input(isTableScan("TEST")))
+                                        ))
+                                ))
                         ))
-                )
-        );
+                ));
     }
 
     private void checkDistinctAggWithColocatedGroupByHash(TestCase testCase) 
throws Exception {
@@ -755,11 +744,15 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
 
     private void checkGroupWithNoAggregateHash(TestCase testCase) throws 
Exception {
         assertPlan(testCase,
-                nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class)
+                nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class)
                         .and(not(hasAggregate()))
                         .and(hasGroups())
                         .and(input(isInstanceOf(IgniteExchange.class)
-                                .and(input(isTableScan("TEST")))
+                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                        .and(not(hasAggregate()))
+                                        .and(hasGroups())
+                                        .and(input(isTableScan("TEST")))
+                                ))
                         ))
                 ));
     }
@@ -812,9 +805,9 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
 
     private void checkGroupsWithOrderByGroupColumnsSingle(TestCase testCase, 
RelCollation collation) throws Exception {
         assertPlan(testCase,
-                isInstanceOf(IgniteColocatedSortAggregate.class)
-                        .and(input(isInstanceOf(IgniteSort.class)
-                                .and(s -> s.collation().equals(collation))
+                isInstanceOf(IgniteSort.class)
+                        .and(s -> s.collation().equals(collation))
+                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
                                 .and(input(isTableScan("TEST")))
                         ))
         );
@@ -822,12 +815,15 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
 
     private void checkGroupsWithOrderByGroupColumnsHash(TestCase testCase, 
RelCollation collation) throws Exception {
         assertPlan(testCase,
-                isInstanceOf(IgniteColocatedSortAggregate.class)
-                        .and(input(isInstanceOf(IgniteExchange.class)
-                                .and(hasDistribution(single()))
-                                .and(input(isInstanceOf(IgniteSort.class)
-                                        .and(s -> 
s.collation().equals(collation))
-                                        .and(input(isTableScan("TEST")))
+                isInstanceOf(IgniteSort.class)
+                        .and(s -> s.collation().equals(collation))
+                        .and(input(isInstanceOf(IgniteProject.class)
+                                
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                                        
.and(input(isTableScan("TEST")))
+                                                ))
+                                        ))
                                 ))
                         ))
         );
@@ -881,31 +877,32 @@ public class AggregatePlannerTest extends 
AbstractAggregatePlannerTest {
     }
 
     private void 
checkDerivedCollationWithOrderBySubsetOfGroupColumnsSingle(TestCase testCase) 
throws Exception {
-        RelCollation requiredCollation = RelCollations.of(
-                TraitUtils.createFieldCollation(1, Collation.DESC_NULLS_FIRST),
-                TraitUtils.createFieldCollation(0, Collation.ASC_NULLS_LAST)
+        RelCollation outputCollation = RelCollations.of(
+                TraitUtils.createFieldCollation(1, Collation.DESC_NULLS_FIRST)
         );
 
-        assertPlan(testCase, isInstanceOf(IgniteColocatedSortAggregate.class)
-                .and(hasCollation(requiredCollation))
-                .and(input(isInstanceOf(IgniteSort.class)
-                        .and(hasCollation(requiredCollation))
-                )));
+        assertPlan(testCase,
+                isInstanceOf(IgniteSort.class)
+                        .and(hasCollation(outputCollation))
+                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)))
+        );
     }
 
     private void 
checkDerivedCollationWithOrderBySubsetOfGroupColumnsHash(TestCase testCase) 
throws Exception {
-        RelCollation requiredCollation = RelCollations.of(
-                TraitUtils.createFieldCollation(1, Collation.DESC_NULLS_FIRST),
-                TraitUtils.createFieldCollation(0, Collation.ASC_NULLS_LAST)
+        RelCollation outputCollation = RelCollations.of(
+                TraitUtils.createFieldCollation(1, Collation.DESC_NULLS_FIRST)
         );
 
-        assertPlan(testCase, isInstanceOf(IgniteColocatedSortAggregate.class)
-                .and(hasCollation(requiredCollation))
-                .and(input(isInstanceOf(IgniteExchange.class)
-                        .and(hasDistribution(single()))
-                        .and(input(isInstanceOf(IgniteSort.class)
-                                .and(hasCollation(requiredCollation))
-                        ))
-                )));
+        assertPlan(testCase,
+                isInstanceOf(IgniteSort.class)
+                        .and(hasCollation(outputCollation))
+                        .and(input(isInstanceOf(IgniteProject.class)
+                                
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                .and(hasDistribution(single()))
+                                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)))
+                                        ))
+                                ))
+                        )));
     }
 }
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ColocatedHashAggregatePlannerTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ColocatedHashAggregatePlannerTest.java
index 93b63b1c0d..fec1474ed0 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ColocatedHashAggregatePlannerTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ColocatedHashAggregatePlannerTest.java
@@ -591,11 +591,9 @@ public class ColocatedHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
         assertPlan(testCase,
                 isInstanceOf(IgniteColocatedHashAggregate.class)
                         .and(hasAggregate())
-                        .and(not(hasDistinctAggregate()))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(hasGroups())
-                                .and(input(isTableScan("TEST")))
-                        )),
+                        .and(hasDistinctAggregate())
+                        .and(hasGroups())
+                        .and(input(isTableScan("TEST"))),
                 disableRules
         );
     }
@@ -604,12 +602,10 @@ public class ColocatedHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
         assertPlan(testCase,
                 isInstanceOf(IgniteColocatedHashAggregate.class)
                         .and(hasAggregate())
-                        .and(not(hasDistinctAggregate()))
-                        
.and(input(isInstanceOf(IgniteColocatedHashAggregate.class)
-                                .and(hasGroups())
-                                .and(input(isInstanceOf(IgniteExchange.class)
-                                        .and(input(isTableScan("TEST")))
-                                ))
+                        .and(hasDistinctAggregate())
+                        .and(hasGroups())
+                        .and(input(isInstanceOf(IgniteExchange.class)
+                                .and(input(isTableScan("TEST")))
                         )),
                 disableRules
         );
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceHashAggregatePlannerTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceHashAggregatePlannerTest.java
index b09e421d5b..11af51270a 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceHashAggregatePlannerTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceHashAggregatePlannerTest.java
@@ -141,22 +141,23 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
         checkDistinctAggWithGroupBySingle(TestCase.CASE_7_2);
         checkDistinctAggWithGroupBySingle(TestCase.CASE_7_3);
 
+        // TODO REMOVE TODO and close ticket
         // TODO replace with calls to test methods after 
https://issues.apache.org/jira/browse/IGNITE-20083 is fixed
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_1A);
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_2A);
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_3A);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_1A);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_2A);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_3A);
 
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_1B);
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_2B);
-        assumeRun("checkDistinctAggWithGroupByHash", TestCase.CASE_7_3B);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_1B);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_2B);
+        checkDistinctAggWithGroupByHash(TestCase.CASE_7_3B);
 
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_1C);
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_2C);
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_3C);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_1C);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_2C);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_3C);
 
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_1D);
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_2D);
-        assumeRun("checkDistinctAggWithColocatedGroupByHash", 
TestCase.CASE_7_3D);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_1D);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_2D);
+        checkDistinctAggWithColocatedGroupByHash(TestCase.CASE_7_3D);
     }
 
     /**
@@ -214,11 +215,11 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
     @Test
     public void distinctWithoutAggregate() throws Exception {
         checkGroupWithNoAggregateSingle(TestCase.CASE_12);
-        // TODO replace with calls to test methods after 
https://issues.apache.org/jira/browse/IGNITE-20083 is resolved
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_12A);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_12B);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_12C);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_12D);
+
+        checkGroupWithNoAggregateHash(TestCase.CASE_12A);
+        checkGroupWithNoAggregateHash(TestCase.CASE_12B);
+        checkGroupWithNoAggregateHash(TestCase.CASE_12C);
+        checkGroupWithNoAggregateHash(TestCase.CASE_12D);
     }
 
     /**
@@ -227,11 +228,11 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
     @Test
     public void distinctWithoutAggregateUseIndex() throws Exception {
         checkGroupWithNoAggregateSingle(TestCase.CASE_13);
-        // TODO replace with calls to test methods after 
https://issues.apache.org/jira/browse/IGNITE-20083 is resolved
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_13A);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_13B);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_13C);
-        assumeRun("checkGroupWithNoAggregateHash", TestCase.CASE_13D);
+
+        checkGroupWithNoAggregateHash(TestCase.CASE_13A);
+        checkGroupWithNoAggregateHash(TestCase.CASE_13B);
+        checkGroupWithNoAggregateHash(TestCase.CASE_13C);
+        checkGroupWithNoAggregateHash(TestCase.CASE_13D);
     }
 
     /**
@@ -436,15 +437,14 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
                 ))
         );
 
-        // TODO Replace with uncommented code after 
https://issues.apache.org/jira/browse/IGNITE-20083 is resolved
-        assumeRun("", TestCase.CASE_21A);
-        assumeRun("", TestCase.CASE_21B);
-        /*
         assertPlan(TestCase.CASE_21A, 
nodeOrAnyChild(isInstanceOf(IgniteMergeJoin.class)
                 .and(input(0, subtreePredicate))
                 .and(input(1, subtreePredicate))
         ), disableRules);
-         */
+        assertPlan(TestCase.CASE_21B, 
nodeOrAnyChild(isInstanceOf(IgniteMergeJoin.class)
+                .and(input(0, subtreePredicate))
+                .and(input(1, subtreePredicate))
+        ), disableRules);
     }
 
     /**
@@ -708,6 +708,29 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
         );
     }
 
+    private void checkDistinctAggWithColocatedGroupByHash(TestCase testCase) 
throws Exception {
+        assertPlan(testCase,
+                nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class)
+                        .and(hasAggregate())
+                        .and(not(hasDistinctAggregate()))
+                        .and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
+                                        .and(not(hasAggregate()))
+                                        .and(hasGroups())
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
+                                                        
.and(not(hasAggregate()))
+                                                        .and(hasGroups())
+                                                        
.and(input(isTableScan("TEST")))
+                                                ))
+                                        ))
+                                ))
+                        ))
+                ),
+                disableRules
+        );
+    }
+
     private void checkAggWithGroupByIndexColumnsSingle(TestCase testCase) 
throws Exception {
         assertPlan(testCase,
                 nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class)
@@ -787,10 +810,8 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
                         .and(s -> s.collation().equals(collation))
                         .and(input(isInstanceOf(IgniteProject.class)
                                 
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
-                                        
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
-                                                // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                                // Why can't Map be pushed 
down to under 'exchange'.
-                                                
.and(input(isInstanceOf(IgniteExchange.class)
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
                                                         
.and(input(isTableScan("TEST")))
                                                 ))
                                         ))
@@ -878,12 +899,9 @@ public class MapReduceHashAggregatePlannerTest extends 
AbstractAggregatePlannerT
                         .and(hasCollation(outputCollation))
                         .and(input(isInstanceOf(IgniteProject.class)
                                 
.and(input(isInstanceOf(IgniteReduceHashAggregate.class)
-                                        
.and(input(isInstanceOf(IgniteMapHashAggregate.class)
-                                                // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                                // Why can't Map be pushed 
down to under 'exchange'.
-                                                
.and(input(isInstanceOf(IgniteExchange.class)
-                                                        
.and(hasDistribution(IgniteDistributions.single()))
-                                                ))
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                
.and(hasDistribution(IgniteDistributions.single()))
+                                                
.and(input(isInstanceOf(IgniteMapHashAggregate.class)))
                                         ))
                                 ))
                         )),
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceSortAggregatePlannerTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceSortAggregatePlannerTest.java
index 34925da593..14d8da0739 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceSortAggregatePlannerTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/MapReduceSortAggregatePlannerTest.java
@@ -522,7 +522,7 @@ public class MapReduceSortAggregatePlannerTest extends 
AbstractAggregatePlannerT
         Predicate<IgniteReduceSortAggregate> inputAgg = 
isInstanceOf(IgniteReduceSortAggregate.class)
                 .and(hasGroupSets(IgniteReduceSortAggregate::getGroupSets, 0))
                 .and(hasCollation(RelCollations.of(0)))
-                .and(input(isInstanceOf(IgniteMapSortAggregate.class)
+                        .and(input(isInstanceOf(IgniteMapSortAggregate.class)
                         .and(hasCollation(RelCollations.of(1)))
                         .and(hasGroupSets(Aggregate::getGroupSets, 1))
                 ));
@@ -846,11 +846,9 @@ public class MapReduceSortAggregatePlannerTest extends 
AbstractAggregatePlannerT
     private void checkGroupsWithOrderBySubsetOfGroupColumnsHash(TestCase 
testCase, RelCollation collation) throws Exception {
         assertPlan(testCase,
                 nodeOrAnyChild(isInstanceOf(IgniteReduceSortAggregate.class)
-                        .and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                // Why can't Map be pushed down to under 
'exchange'.
-                                .and(input(isInstanceOf(IgniteExchange.class)
-                                        .and(hasDistribution(single()))
+                        .and(input(isInstanceOf(IgniteExchange.class)
+                                .and(hasDistribution(single()))
+                                
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
                                         
.and(input(isInstanceOf(IgniteSort.class)
                                                 .and(s -> 
s.collation().equals(collation))
                                                 
.and(input(isTableScan("TEST")))
@@ -868,8 +866,6 @@ public class MapReduceSortAggregatePlannerTest extends 
AbstractAggregatePlannerT
                         .and(input(isInstanceOf(IgniteProject.class)
                                 
.and(input(isInstanceOf(IgniteReduceSortAggregate.class)
                                         
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                                // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                                // Why can't Map be pushed 
down to under 'exchange'.
                                                 
.and(input(isInstanceOf(IgniteSort.class)
                                                         .and(s -> 
s.collation().equals(collation))
                                                         
.and(input(isTableScan("TEST")
@@ -888,11 +884,9 @@ public class MapReduceSortAggregatePlannerTest extends 
AbstractAggregatePlannerT
                         .and(s -> 
s.collation().equals(TraitUtils.createCollation(List.of(0, 1, 2))))
                         .and(input(isInstanceOf(IgniteProject.class)
                                 
.and(input(isInstanceOf(IgniteReduceSortAggregate.class)
-                                        
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                                // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                                // Why can't Map be pushed 
down to under 'exchange'.
-                                                
.and(input(isInstanceOf(IgniteExchange.class)
-                                                        
.and(hasDistribution(single()))
+                                        
.and(input(isInstanceOf(IgniteExchange.class)
+                                                .and(hasDistribution(single()))
+                                                
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
                                                         
.and(input(isInstanceOf(IgniteSort.class)
                                                                 .and(s -> 
s.collation().equals(collation))
                                                                 
.and(input(isTableScan("TEST")
@@ -994,11 +988,9 @@ public class MapReduceSortAggregatePlannerTest extends 
AbstractAggregatePlannerT
                 isInstanceOf(IgniteProject.class)
                         .and(hasCollation(outputCollation))
                         
.and(input(isInstanceOf(IgniteReduceSortAggregate.class)
-                                
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
-                                        // TODO: 
https://issues.apache.org/jira/browse/IGNITE-20095
-                                        // Why can't Map be pushed down to 
under 'exchange'.
-                                        
.and(input(isInstanceOf(IgniteExchange.class)
-                                                .and(hasDistribution(single()))
+                                .and(input(isInstanceOf(IgniteExchange.class)
+                                        .and(hasDistribution(single()))
+                                        
.and(input(isInstanceOf(IgniteMapSortAggregate.class)
                                                 
.and(input(isInstanceOf(IgniteSort.class)
                                                         
.and(hasCollation(requiredCollation))
                                                 ))


Reply via email to