use of io.dingodb.calcite.rel.DingoAggregate in project dingo by dingodb.
the class DingoAggregateRule method onMatch.
@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
Aggregate rel = call.rel(0);
// AVG must be transformed to SUM/COUNT before.
if (rel.getAggCallList().stream().anyMatch(agg -> agg.getAggregation().getKind() == SqlKind.AVG)) {
return;
}
RelOptCluster cluster = rel.getCluster();
TupleMapping keyMapping = getAggKeys(rel);
List<Agg> aggList = getAggList(rel);
call.transformTo(new DingoReduce(cluster, rel.getTraitSet().replace(DingoConventions.ROOT), new DingoExchange(cluster, rel.getTraitSet().replace(DingoConventions.PARTITIONED), new DingoAggregate(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convert(rel.getInput(), DingoConventions.DISTRIBUTED), keyMapping, aggList, rel.getRowType())), keyMapping, aggList));
}
use of io.dingodb.calcite.rel.DingoAggregate in project dingo by dingodb.
the class TestPhysicalPlan method testAvg2.
@Test
public void testAvg2() throws SqlParseException {
String sql = "select name, avg(id), avg(amount) from test group by name";
RelNode relNode = parse(sql);
AssertRelNode assertAgg = Assert.relNode(relNode).isA(EnumerableRoot.class).convention(EnumerableConvention.INSTANCE).singleInput().isA(DingoProject.class).convention(DingoConventions.ROOT).singleInput().isA(DingoReduce.class).convention(DingoConventions.ROOT).singleInput().isA(DingoExchange.class).convention(DingoConventions.PARTITIONED).singleInput().isA(DingoAggregate.class).convention(DingoConventions.DISTRIBUTED);
DingoAggregate agg = (DingoAggregate) assertAgg.getInstance();
assertThat(agg.getAggList()).map(Object::getClass).map(Class::getSimpleName).contains("SumAgg", "CountAgg");
assertAgg.singleInput().isA(DingoPartScan.class).convention(DingoConventions.DISTRIBUTED);
}
use of io.dingodb.calcite.rel.DingoAggregate in project dingo by dingodb.
the class TestPhysicalPlan method testAvg1.
@Test
public void testAvg1() throws SqlParseException {
String sql = "select name, avg(amount) from test group by name";
RelNode relNode = parse(sql);
AssertRelNode assertAgg = Assert.relNode(relNode).isA(EnumerableRoot.class).convention(EnumerableConvention.INSTANCE).singleInput().isA(DingoProject.class).convention(DingoConventions.ROOT).singleInput().isA(DingoReduce.class).convention(DingoConventions.ROOT).singleInput().isA(DingoExchange.class).convention(DingoConventions.PARTITIONED).singleInput().isA(DingoAggregate.class).convention(DingoConventions.DISTRIBUTED);
DingoAggregate agg = (DingoAggregate) assertAgg.getInstance();
assertThat(agg.getAggList()).map(Object::getClass).map(Class::getSimpleName).contains("SumAgg", "CountAgg");
assertAgg.singleInput().isA(DingoPartScan.class).convention(DingoConventions.DISTRIBUTED);
}
use of io.dingodb.calcite.rel.DingoAggregate in project dingo by dingodb.
the class TestPhysicalPlan method testAvg.
@Test
public void testAvg() throws SqlParseException {
String sql = "select avg(amount) from test";
RelNode relNode = parse(sql);
AssertRelNode assertAgg = Assert.relNode(relNode).isA(EnumerableRoot.class).convention(EnumerableConvention.INSTANCE).singleInput().isA(DingoProject.class).convention(DingoConventions.ROOT).singleInput().isA(DingoReduce.class).convention(DingoConventions.ROOT).singleInput().isA(DingoExchange.class).convention(DingoConventions.PARTITIONED).singleInput().isA(DingoAggregate.class).convention(DingoConventions.DISTRIBUTED);
DingoAggregate agg = (DingoAggregate) assertAgg.getInstance();
assertThat(agg.getAggList()).map(Object::getClass).map(Class::getSimpleName).contains("SumAgg", "CountAgg");
assertAgg.singleInput().isA(DingoPartScan.class).convention(DingoConventions.DISTRIBUTED);
}
Aggregations