Search in sources :

Example 1 with IgniteSingleAggregateBase

use of org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase in project ignite-3 by apache.

the class AggregatePlannerTest method distribution.

/**
 * Test that aggregate has single distribution output even if parent node accept random distibution inputs.
 *
 * @throws Exception If failed.
 */
@ParameterizedTest
@EnumSource
public void distribution(AggregateAlgorithm algo) throws Exception {
    TestTable tbl = createAffinityTable().addIndex(RelCollations.of(ImmutableIntList.of(3)), "grp0");
    IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
    publicSchema.addTable("TEST", tbl);
    String sql = "SELECT AVG(val0), grp0 FROM TEST GROUP BY grp0 UNION ALL SELECT val0, grp0 FROM test";
    IgniteRel phys = physicalPlan(sql, publicSchema, concat(algo.rulesToDisable, "SortMapReduceAggregateConverterRule", "HashMapReduceAggregateConverterRule"));
    IgniteSingleAggregateBase singleAgg = findFirstNode(phys, byClass(algo.single));
    assertEquals(IgniteDistributions.single(), TraitUtils.distribution(singleAgg));
    phys = physicalPlan(sql, publicSchema, concat(algo.rulesToDisable, "SortSingleAggregateConverterRule", "HashSingleAggregateConverterRule"));
    IgniteReduceAggregateBase rdcAgg = findFirstNode(phys, byClass(algo.reduce));
    assertEquals(IgniteDistributions.single(), TraitUtils.distribution(rdcAgg));
}
Also used : IgniteReduceAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteReduceAggregateBase) IgniteRel(org.apache.ignite.internal.sql.engine.rel.IgniteRel) IgniteSingleAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with IgniteSingleAggregateBase

use of org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase in project ignite-3 by apache.

the class AggregatePlannerTest method singleWithIndex.

/**
 * SingleWithIndex.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@ParameterizedTest
@EnumSource
public void singleWithIndex(AggregateAlgorithm algo) throws Exception {
    TestTable tbl = createBroadcastTable().addIndex(RelCollations.of(ImmutableIntList.of(3, 4)), "grp0_grp1");
    IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
    publicSchema.addTable("TEST", tbl);
    String sql = "SELECT AVG(val0) FILTER(WHERE val1 > 10) FROM test GROUP BY grp0";
    IgniteRel phys = physicalPlan(sql, publicSchema, algo.rulesToDisable);
    IgniteSingleAggregateBase agg = findFirstNode(phys, byClass(algo.single));
    assertNotNull(agg, "Invalid plan\n" + RelOptUtil.toString(phys));
    assertThat("Invalid plan\n" + RelOptUtil.toString(phys), first(agg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class));
    if (algo == AggregateAlgorithm.SORT) {
        assertNotNull(findFirstNode(phys, byClass(IgniteIndexScan.class)));
    }
}
Also used : SqlAvgAggFunction(org.apache.calcite.sql.fun.SqlAvgAggFunction) IgniteRel(org.apache.ignite.internal.sql.engine.rel.IgniteRel) IgniteSingleAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with IgniteSingleAggregateBase

use of org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase in project ignite-3 by apache.

the class AggregatePlannerTest method singleWithoutIndex.

/**
 * SingleWithoutIndex.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@ParameterizedTest
@EnumSource
public void singleWithoutIndex(AggregateAlgorithm algo) throws Exception {
    TestTable tbl = createBroadcastTable().addIndex(RelCollations.of(ImmutableIntList.of(1, 2)), "val0_val1");
    IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
    publicSchema.addTable("TEST", tbl);
    String sql = "SELECT AVG(val0) FROM test GROUP BY grp0";
    IgniteRel phys = physicalPlan(sql, publicSchema, algo.rulesToDisable);
    IgniteSingleAggregateBase agg = findFirstNode(phys, byClass(algo.single));
    assertNotNull(agg, "Invalid plan\n" + RelOptUtil.toString(phys));
    assertThat("Invalid plan\n" + RelOptUtil.toString(phys), first(agg.getAggCallList()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class));
    if (algo == AggregateAlgorithm.SORT) {
        assertNotNull(findFirstNode(phys, byClass(IgniteSort.class)));
    }
}
Also used : SqlAvgAggFunction(org.apache.calcite.sql.fun.SqlAvgAggFunction) IgniteRel(org.apache.ignite.internal.sql.engine.rel.IgniteRel) IgniteSingleAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

IgniteRel (org.apache.ignite.internal.sql.engine.rel.IgniteRel)3 IgniteSingleAggregateBase (org.apache.ignite.internal.sql.engine.rel.agg.IgniteSingleAggregateBase)3 IgniteSchema (org.apache.ignite.internal.sql.engine.schema.IgniteSchema)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 SqlAvgAggFunction (org.apache.calcite.sql.fun.SqlAvgAggFunction)2 IgniteReduceAggregateBase (org.apache.ignite.internal.sql.engine.rel.agg.IgniteReduceAggregateBase)1