use of io.dingodb.calcite.assertion.AssertRelNode in project dingo by dingodb.
the class TestLogicalPlan method testSort.
@Test
public void testSort() throws SqlParseException {
String sql = "select * from test order by name, amount desc";
RelRoot relRoot = parse(sql);
AssertRelNode assertSort = Assert.relNode(relRoot.rel);
assertSort.isA(LogicalSort.class).convention(Convention.NONE).singleInput().isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
LogicalSort logicalSort = (LogicalSort) assertSort.getInstance();
List<RelFieldCollation> collations = logicalSort.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(logicalSort.fetch).isNull();
assertThat(logicalSort.offset).isNull();
}
use of io.dingodb.calcite.assertion.AssertRelNode 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.assertion.AssertRelNode in project dingo by dingodb.
the class TestPhysicalPlan method testSortLimit.
@Test
public void testSortLimit() throws SqlParseException {
String sql = "select * from test order by name limit 3";
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(dingoSort.fetch).isNotNull();
assertThat(RexLiteral.intValue(dingoSort.fetch)).isEqualTo(3);
assertThat(dingoSort.offset).isNull();
}
use of io.dingodb.calcite.assertion.AssertRelNode 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.assertion.AssertRelNode in project dingo by dingodb.
the class TestLogicalPlan method testLimitOffset.
@Test
public void testLimitOffset() throws SqlParseException {
String sql = "select * from test limit 3 offset 2";
RelRoot relRoot = parse(sql);
AssertRelNode assertSort = Assert.relNode(relRoot.rel);
assertSort.isA(LogicalSort.class).convention(Convention.NONE).singleInput().isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
LogicalSort logicalSort = (LogicalSort) assertSort.getInstance();
assertThat(logicalSort.fetch).isNotNull();
assertThat(RexLiteral.intValue(logicalSort.fetch)).isEqualTo(3);
assertThat(logicalSort.offset).isNotNull();
assertThat(RexLiteral.intValue(logicalSort.offset)).isEqualTo(2);
}
Aggregations