use of io.dingodb.calcite.assertion.AssertRelNode in project dingo by dingodb.
the class TestPhysicalPlan method testOffsetLimit.
@Test
public void testOffsetLimit() throws SqlParseException {
String sql = "select * from test limit 3 offset 2";
RelNode relNode = parse(sql);
AssertRelNode assertSort = Assert.relNode(relNode).isA(EnumerableRoot.class).convention(EnumerableConvention.INSTANCE).singleInput();
assertSort.isA(DingoSort.class).convention(DingoConventions.ROOT).singleInput().isA(DingoCoalesce.class).convention(DingoConventions.ROOT).singleInput().isA(DingoExchange.class).convention(DingoConventions.PARTITIONED).singleInput().isA(DingoPartScan.class).convention(DingoConventions.DISTRIBUTED);
DingoSort dingoSort = (DingoSort) assertSort.getInstance();
List<RelFieldCollation> collations = dingoSort.getCollation().getFieldCollations();
assertThat(collations).isEmpty();
assertThat(dingoSort.fetch).isNotNull();
assertThat(RexLiteral.intValue(dingoSort.fetch)).isEqualTo(3);
assertThat(dingoSort.offset).isNotNull();
assertThat(RexLiteral.intValue(dingoSort.offset)).isEqualTo(2);
}
use of io.dingodb.calcite.assertion.AssertRelNode in project dingo by dingodb.
the class TestPhysicalPlan method testSort.
@Test
public void testSort() throws SqlParseException {
String sql = "select * from test order by name, amount desc";
RelNode relNode = parse(sql);
AssertRelNode assertSort = Assert.relNode(relNode).isA(EnumerableRoot.class).convention(EnumerableConvention.INSTANCE).singleInput();
assertSort.isA(DingoSort.class).convention(DingoConventions.ROOT).singleInput().isA(DingoCoalesce.class).convention(DingoConventions.ROOT).singleInput().isA(DingoExchange.class).convention(DingoConventions.PARTITIONED).singleInput().isA(DingoPartScan.class).convention(DingoConventions.DISTRIBUTED);
DingoSort dingoSort = (DingoSort) assertSort.getInstance();
List<RelFieldCollation> collations = dingoSort.getCollation().getFieldCollations();
assertThat(collations.get(0)).hasFieldOrPropertyWithValue("fieldIndex", 1).hasFieldOrPropertyWithValue("direction", ASCENDING).hasFieldOrPropertyWithValue("nullDirection", LAST);
assertThat(collations.get(1)).hasFieldOrPropertyWithValue("fieldIndex", 2).hasFieldOrPropertyWithValue("direction", DESCENDING).hasFieldOrPropertyWithValue("nullDirection", FIRST);
assertThat(dingoSort.fetch).isNull();
assertThat(dingoSort.offset).isNull();
}
use of io.dingodb.calcite.assertion.AssertRelNode 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