Search in sources :

Example 1 with IgniteMapAggregateBase

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

the class AggregatePlannerTest method mapReduceGroupBy.

/**
 * MapReduceGroupBy.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@ParameterizedTest
@EnumSource
public void mapReduceGroupBy(AggregateAlgorithm algo) throws Exception {
    TestTable tbl = createAffinityTable();
    IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
    publicSchema.addTable("TEST", tbl);
    String sql = "SELECT AVG(val0) FILTER (WHERE val1 > 10) FROM test GROUP BY grp1, grp0";
    IgniteRel phys = physicalPlan(sql, publicSchema, algo.rulesToDisable);
    IgniteMapAggregateBase mapAgg = findFirstNode(phys, byClass(algo.map));
    IgniteReduceAggregateBase rdcAgg = findFirstNode(phys, byClass(algo.reduce));
    assertNotNull(rdcAgg, "Invalid plan\n" + RelOptUtil.toString(phys, SqlExplainLevel.ALL_ATTRIBUTES));
    assertNotNull(mapAgg, "Invalid plan\n" + RelOptUtil.toString(phys));
    assertThat("Invalid plan\n" + RelOptUtil.toString(phys), first(rdcAgg.getAggregateCalls()).getAggregation(), IsInstanceOf.instanceOf(SqlAvgAggFunction.class));
    assertThat("Invalid plan\n" + RelOptUtil.toString(phys), first(mapAgg.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) IgniteReduceAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteReduceAggregateBase) IgniteRel(org.apache.ignite.internal.sql.engine.rel.IgniteRel) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) IgniteMapAggregateBase(org.apache.ignite.internal.sql.engine.rel.agg.IgniteMapAggregateBase) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

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