zstan commented on code in PR #1675: URL: https://github.com/apache/ignite-3/pull/1675#discussion_r1119618369
########## modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ColocatedSortAggregatePlannerTest.java: ########## @@ -0,0 +1,382 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.sql.engine.planner; + +import static java.util.function.Predicate.not; + +import java.util.List; +import java.util.function.Predicate; +import org.apache.calcite.rel.RelCollation; +import org.apache.calcite.rel.RelNode; +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.IgniteSort; +import org.apache.ignite.internal.sql.engine.rel.agg.IgniteColocatedSortAggregate; +import org.apache.ignite.internal.sql.engine.schema.IgniteSchema; +import org.apache.ignite.internal.sql.engine.trait.TraitUtils; +import org.apache.ignite.internal.util.ArrayUtils; + +/** + * Test to verify ColocatedSortAggregateConverterRule usage by a planner. + */ +public class ColocatedSortAggregatePlannerTest extends AbstractAggregatePlannerTest { + private final String[] disableRules = { + "MapReduceHashAggregateConverterRule", + "MapReduceSortAggregateConverterRule", + "ColocatedHashAggregateConverterRule" + }; + + @Override + protected String[] disabledRules() { + return disableRules; + } + + @Override + protected void checkTestCase1(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(hasChildThat(isTableScan("TEST"))) + ) + ); + } + + @Override + protected void checkTestCase2(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isTableScan("TEST"))) + )) + ) + ); + } + + @Override + protected void checkTestCase3(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(hasGroups()) + .and(hasChildThat(isTableScan("TEST"))) + ) + ); + } + + @Override + protected void checkTestCase4(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isInstanceOf(IgniteSort.class) + .and(input(isTableScan("TEST"))) + )) + )) + ) + ); + } + + @Override + protected void checkTestCase5(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(hasChildThat(isIndexScan("TEST", "grp0_grp1"))) + ) + ); + } + + @Override + protected void checkTestCase6(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasAggregate()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isIndexScan("TEST", "grp0_grp1"))) + )) + ) + ); + } + + @Override + protected void checkTestCase7(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasDistinctAggregate()) + .and(input(isTableScan("TEST"))) + ) + ); + } + + @Override + protected void checkTestCase8(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasDistinctAggregate()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isTableScan("TEST"))) + )) + ) + ); + } + + @Override + protected void checkTestCase9(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(not(hasAggregate())) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteSort.class) + .and(input(isTableScan("TEST"))) + )) + ) + ); + } + + @Override + protected void checkTestCase10(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(not(hasAggregate())) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isInstanceOf(IgniteSort.class) + .and(input(isTableScan("TEST"))) + )) + )) + ) + ); + } + + @Override + protected void checkTestCase11(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(not(hasAggregate())) + .and(hasGroups()) + .and(input(isIndexScan("TEST", "grp0_grp1"))) + ) + ); + } + + @Override + protected void checkTestCase12(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(not(hasAggregate())) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isIndexScan("TEST", "grp0_grp1"))) + )) + ) + ); + } + + @Override + protected void checkTestCase13(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasDistinctAggregate()) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteSort.class) + .and(input(isTableScan("TEST"))) + )) + ) + ); + } + + @Override + protected void checkTestCase14(String sql, IgniteSchema schema) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(hasDistinctAggregate()) + .and(hasGroups()) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isInstanceOf(IgniteSort.class) + .and(input(isTableScan("TEST"))) + )) + )) + ) + ); + } + + @Override + protected void checkTestCase15(String sql, IgniteSchema schema, String... additionalRules) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(input(isIndexScan("TEST", "val0"))) + ), + ArrayUtils.concat(disabledRules(), additionalRules)); + } + + @Override + protected void checkTestCase16(String sql, IgniteSchema schema, String... additionalRules) throws Exception { + assertPlan(sql, schema, + nodeOrAnyChild(isInstanceOf(IgniteColocatedSortAggregate.class) + .and(input(isInstanceOf(IgniteExchange.class) + .and(input(isIndexScan("TEST", "val0"))) + )) + ), + ArrayUtils.concat(disabledRules(), additionalRules)); + } + + @Override + protected void checkTestCase17(String sql, IgniteSchema schema, RelCollation collation) throws Exception { Review Comment: the same as from parent implementation, and seems there are numerous the same issues, is it ok ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
