use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot 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);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.
the class TestLogicalPlan method testAggregateGroup.
@Test
public void testAggregateGroup() throws SqlParseException {
String sql = "select name, sum(amount) from test group by name";
RelRoot relRoot = parse(sql);
Assert.relNode(relRoot.rel).isA(LogicalAggregate.class).convention(Convention.NONE).singleInput().isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.
the class TestLogicalPlan method testProjectFilterScan.
@Test
public void testProjectFilterScan() throws SqlParseException {
String sql = "select name, amount from test where amount > 3.0";
RelRoot relRoot = parse(sql);
Assert.relNode(relRoot.rel).isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(LogicalFilter.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.
the class TestLogicalPlan method testDelete.
@Test
public void testDelete() throws SqlParseException {
String sql = "delete from test where id = 3";
RelRoot relRoot = parse(sql);
Assert.relNode(relRoot.rel).isA(LogicalTableModify.class).convention(Convention.NONE).prop("operation", TableModify.Operation.DELETE).singleInput().isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(LogicalFilter.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.
the class TestRexConverter method test.
@ParameterizedTest
@MethodSource("getParameters")
public void test(String rex, String result) throws SqlParseException {
String sql = "select " + rex + " from test";
SqlNode sqlNode = parser.parse(sql);
sqlNode = parser.validate(sqlNode);
RelRoot relRoot = parser.convert(sqlNode);
LogicalProject project = (LogicalProject) relRoot.rel;
RexNode rexNode = project.getProjects().get(0);
log.info("rexNode = {}", rexNode);
Expr expr = RexConverter.convert(rexNode);
assertThat(expr.toString()).isEqualTo(result);
}
Aggregations