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 35bed7de594af30c75890dfa629cc6edc24e4f2e Author: amashenkov <andrey.mashen...@gmail.com> AuthorDate: Sun Mar 31 13:40:05 2024 +0300 Fix tests. --- .../sql/engine/planner/AggregatePlannerTest.java | 172 +++++++++++---------- .../planner/MapReduceHashAggregatePlannerTest.java | 103 ++++++------ .../planner/MapReduceSortAggregatePlannerTest.java | 64 ++++---- 3 files changed, 173 insertions(+), 166 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 d3ab2e6750..b1ea5b2287 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 @@ -30,6 +30,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; @@ -116,9 +117,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); @@ -248,22 +248,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); } /** @@ -365,14 +351,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))); } /** @@ -380,32 +366,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))); } @@ -495,17 +459,35 @@ 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> avgAgg = (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 = nodeOrAnyChild(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(avgAgg).test(in.getAggCallList())) .and(input(isTableScan("TEST"))) )); @@ -626,14 +608,20 @@ public class AggregatePlannerTest extends AbstractAggregatePlannerTest { private void checkDistinctAggHash(TestCase testCase) throws Exception { assertPlan(testCase, - isInstanceOf(IgniteColocatedHashAggregate.class) + nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class) .and(hasAggregate()) - .and(hasDistinctAggregate()) - .and(hasGroups()) - .and(input(isInstanceOf(IgniteExchange.class) - .and(input(isTableScan("TEST"))) + .and(not(hasDistinctAggregate())) + .and(input(isInstanceOf(IgniteReduceHashAggregate.class) + .and(not(hasAggregate())) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isInstanceOf(IgniteMapHashAggregate.class) + .and(not(hasAggregate())) + .and(input(isTableScan("TEST"))) + )) + )) )) - ); + )); } private void checkColocatedDistinctAggHash(TestCase testCase) throws Exception { @@ -665,13 +653,20 @@ public class AggregatePlannerTest extends AbstractAggregatePlannerTest { private void checkDistinctAggWithGroupByHash(TestCase testCase) throws Exception { assertPlan(testCase, nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class) - .and(hasDistinctAggregate()) - .and(hasGroups()) - .and(input(isInstanceOf(IgniteExchange.class) - .and(input(isTableScan("TEST"))) + .and(hasAggregate()) + .and(not(hasDistinctAggregate())) + .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 { @@ -729,11 +724,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"))) + )) )) )); } @@ -786,9 +785,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"))) )) ); @@ -796,12 +795,13 @@ 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(IgniteReduceHashAggregate.class) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isInstanceOf(IgniteMapHashAggregate.class) + .and(input(isTableScan("TEST"))) + )) )) )) ); @@ -809,11 +809,15 @@ public class AggregatePlannerTest extends AbstractAggregatePlannerTest { private void checkCountDistinctHash(TestCase testCase) throws Exception { assertPlan(testCase, nodeOrAnyChild(isInstanceOf(IgniteColocatedHashAggregate.class) - .and(hasNoGroupSets(IgniteColocatedHashAggregate::getGroupSets)) - .and(hasAggregate()) - .and(hasDistinctAggregate()) - .and(input(isInstanceOf(IgniteExchange.class) - .and(hasDistribution(single())) + .and(nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class) + .and(hasGroupSets(IgniteReduceHashAggregate::getGroupSets, 0)) + .and(input(isInstanceOf(IgniteExchange.class) + .and(hasDistribution(single()) + .and(input(isInstanceOf(IgniteMapHashAggregate.class) + .and(hasGroupSets(IgniteMapHashAggregate::getGroupSets, 1)) + )) + ) + )) )) )); } 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 5d1813b1b0..e6c26585e8 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 @@ -139,22 +139,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); } /** @@ -212,11 +213,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); } /** @@ -225,11 +226,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); } /** @@ -434,15 +435,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); } /** @@ -460,7 +460,7 @@ public class MapReduceHashAggregatePlannerTest extends AbstractAggregatePlannerT return Objects.equals(aggName, "$SUM0") && a.getArgList().equals(List.of(1)); }; - Predicate<RelNode> nonColocated = hasChildThat(isInstanceOf(IgniteReduceHashAggregate.class) + Predicate<RelNode> nonColocated = nodeOrAnyChild(isInstanceOf(IgniteReduceHashAggregate.class) .and(in -> hasAggregates(countReduce).test(in.getAggregateCalls())) .and(input(isInstanceOf(IgniteExchange.class) .and(input(isInstanceOf(IgniteMapHashAggregate.class) @@ -525,8 +525,7 @@ public class MapReduceHashAggregatePlannerTest extends AbstractAggregatePlannerT .and(hasNoGroupSets(IgniteReduceHashAggregate::getGroupSets)) .and(input(isInstanceOf(IgniteMapHashAggregate.class) .and(hasNoGroupSets(IgniteMapHashAggregate::getGroupSets)) - .and(input(isInstanceOf(IgniteProject.class).and(input(inputAgg))) - )) + .and(input(inputAgg))) )), disableRules); } @@ -686,6 +685,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) @@ -748,11 +770,9 @@ public class MapReduceHashAggregatePlannerTest extends AbstractAggregatePlannerT assertPlan(testCase, isInstanceOf(IgniteSort.class) .and(s -> s.collation().equals(collation)) - .and(input(isInstanceOf(IgniteProject.class) - .and(input(isInstanceOf(IgniteReduceHashAggregate.class) - .and(input(isInstanceOf(IgniteMapHashAggregate.class) - .and(input(isTableScan("TEST"))) - )) + .and(input(isInstanceOf(IgniteReduceHashAggregate.class) + .and(input(isInstanceOf(IgniteMapHashAggregate.class) + .and(input(isTableScan("TEST"))) )) )), disableRules @@ -763,14 +783,10 @@ public class MapReduceHashAggregatePlannerTest extends AbstractAggregatePlannerT assertPlan(testCase, isInstanceOf(IgniteSort.class) .and(s -> s.collation().equals(collation)) - .and(input(isInstanceOf(IgniteProject.class) - .and(input(isInstanceOf(IgniteReduceHashAggregate.class) + .and(input(isInstanceOf(IgniteReduceHashAggregate.class) + .and(input(isInstanceOf(IgniteExchange.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(isTableScan("TEST"))) - )) + .and(input(isTableScan("TEST"))) )) )) )), @@ -793,8 +809,7 @@ public class MapReduceHashAggregatePlannerTest extends AbstractAggregatePlannerT .and(hasNoGroupSets(IgniteReduceHashAggregate::getGroupSets)) .and(input(isInstanceOf(IgniteMapHashAggregate.class) .and(hasNoGroupSets(IgniteMapHashAggregate::getGroupSets)) - .and(input(isInstanceOf(IgniteProject.class).and(input(inputAgg))) - )) + .and(input(inputAgg))) )), disableRules); } 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 eb74c71ab2..c569b63d4f 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 @@ -461,7 +461,7 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT Predicate<AggregateCall> countReduce = (a) -> Objects.equals(a.getAggregation().getName(), "$SUM0") && a.getArgList().equals(List.of(1)); - Predicate<RelNode> nonColocated = hasChildThat(isInstanceOf(IgniteReduceSortAggregate.class) + Predicate<RelNode> nonColocated = nodeOrAnyChild(isInstanceOf(IgniteReduceSortAggregate.class) .and(in -> hasAggregates(countReduce).test(in.getAggregateCalls())) .and(input(isInstanceOf(IgniteExchange.class) .and(hasDistribution(single())) @@ -499,12 +499,12 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT .and(in -> hasAggregates(sumReduce, sum0Reduce).test(in.getAggregateCalls())) .and(input(isInstanceOf(IgniteProject.class) .and(input(isInstanceOf(IgniteExchange.class) - .and(hasDistribution(single())) - .and(input(isInstanceOf(IgniteMapSortAggregate.class) - .and(in -> hasAggregates(sumMap, countMap).test(in.getAggCallList())) - ) - )) - )))); + .and(hasDistribution(single())) + .and(input(isInstanceOf(IgniteMapSortAggregate.class) + .and(in -> hasAggregates(sumMap, countMap).test(in.getAggCallList())) + ) + )) + )))); assertPlan(TestCase.CASE_23, nonColocated, disableRules); assertPlan(TestCase.CASE_23A, nonColocated, disableRules); @@ -520,9 +520,9 @@ 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(hasCollation(RelCollations.of(1))) - .and(hasGroupSets(Aggregate::getGroupSets, 1)) + .and(input(isInstanceOf(IgniteMapSortAggregate.class) + .and(hasCollation(RelCollations.of(1))) + .and(hasGroupSets(Aggregate::getGroupSets, 1)) )); assertPlan(TestCase.CASE_24_1, nodeOrAnyChild(isInstanceOf(IgniteReduceSortAggregate.class) @@ -531,8 +531,7 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT .and(input(isInstanceOf(IgniteMapSortAggregate.class) .and(hasNoGroupSets(IgniteMapSortAggregate::getGroupSets)) .and(hasCollation(RelCollations.EMPTY)) - .and(input(isInstanceOf(IgniteProject.class).and(input(inputAgg))) - )) + .and(input(inputAgg))) )), disableRules); } @@ -824,11 +823,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"))) @@ -843,15 +840,11 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT assertPlan(testCase, isInstanceOf(IgniteSort.class) .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(IgniteSort.class) - .and(s -> s.collation().equals(collation)) - .and(input(isTableScan("TEST") - )) + .and(input(isInstanceOf(IgniteReduceSortAggregate.class) + .and(input(isInstanceOf(IgniteMapSortAggregate.class) + .and(input(isInstanceOf(IgniteSort.class) + .and(s -> s.collation().equals(collation)) + .and(input(isTableScan("TEST") )) )) )) @@ -864,17 +857,13 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT assertPlan(testCase, isInstanceOf(IgniteSort.class) .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(IgniteReduceSortAggregate.class) + .and(input(isInstanceOf(IgniteExchange.class) + .and(hasDistribution(single())) .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(IgniteSort.class) - .and(s -> s.collation().equals(collation)) - .and(input(isTableScan("TEST") - )) + .and(input(isInstanceOf(IgniteSort.class) + .and(s -> s.collation().equals(collation)) + .and(input(isTableScan("TEST") )) )) )) @@ -902,8 +891,7 @@ public class MapReduceSortAggregatePlannerTest extends AbstractAggregatePlannerT .and(input(isInstanceOf(IgniteMapSortAggregate.class) .and(hasNoGroupSets(IgniteMapSortAggregate::getGroupSets)) .and(hasCollation(RelCollations.EMPTY)) - .and(input(isInstanceOf(IgniteProject.class).and(input(inputAgg))) - )) + .and(input(inputAgg))) )), disableRules); }