Search in sources :

Example 36 with RelRoot

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.

the class TestLogicalPlan method parse.

private static RelRoot parse(String sql) throws SqlParseException {
    SqlNode sqlNode = parser.parse(sql);
    sqlNode = parser.validate(sqlNode);
    RelRoot relRoot = parser.convert(sqlNode);
    log.info("relRoot = {}", relRoot);
    return relRoot;
}
Also used : RelRoot(org.apache.calcite.rel.RelRoot) SqlNode(org.apache.calcite.sql.SqlNode)

Example 37 with RelRoot

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.

the class TestLogicalPlan method testProjectScan.

@Test
public void testProjectScan() throws SqlParseException {
    String sql = "select name, amount from test";
    RelRoot relRoot = parse(sql);
    Assert.relNode(relRoot.rel).isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
}
Also used : DingoTableScan(io.dingodb.calcite.rel.DingoTableScan) RelRoot(org.apache.calcite.rel.RelRoot) NlsString(org.apache.calcite.util.NlsString) Test(org.junit.jupiter.api.Test)

Example 38 with RelRoot

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.

the class TestLogicalPlan method testSimple.

@Test
public void testSimple() throws SqlParseException {
    String sql = "select 1";
    RelRoot relRoot = parse(sql);
    Assert.relNode(relRoot.rel).isA(LogicalValues.class).convention(Convention.NONE);
}
Also used : RelRoot(org.apache.calcite.rel.RelRoot) NlsString(org.apache.calcite.util.NlsString) LogicalValues(org.apache.calcite.rel.logical.LogicalValues) Test(org.junit.jupiter.api.Test)

Example 39 with RelRoot

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.

the class TestLogicalPlan method testFilterScan.

@Test
public void testFilterScan() throws SqlParseException {
    String sql = "select * from test where name = 'Alice' and 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);
}
Also used : DingoTableScan(io.dingodb.calcite.rel.DingoTableScan) RelRoot(org.apache.calcite.rel.RelRoot) NlsString(org.apache.calcite.util.NlsString) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) Test(org.junit.jupiter.api.Test)

Example 40 with RelRoot

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelRoot in project dingo by dingodb.

the class TestLogicalPlan method testUpdate.

@Test
public void testUpdate() throws SqlParseException {
    String sql = "update test set amount = 2.0 where id = 1";
    RelRoot relRoot = parse(sql);
    Assert.relNode(relRoot.rel).isA(LogicalTableModify.class).convention(Convention.NONE).prop("operation", TableModify.Operation.UPDATE).singleInput().isA(LogicalProject.class).convention(Convention.NONE).singleInput().isA(LogicalFilter.class).convention(Convention.NONE).singleInput().isA(DingoTableScan.class).convention(DingoConventions.DINGO);
}
Also used : LogicalTableModify(org.apache.calcite.rel.logical.LogicalTableModify) DingoTableScan(io.dingodb.calcite.rel.DingoTableScan) RelRoot(org.apache.calcite.rel.RelRoot) NlsString(org.apache.calcite.util.NlsString) LogicalProject(org.apache.calcite.rel.logical.LogicalProject) Test(org.junit.jupiter.api.Test)

Aggregations

RelRoot (org.apache.calcite.rel.RelRoot)76 SqlNode (org.apache.calcite.sql.SqlNode)29 RelNode (org.apache.calcite.rel.RelNode)22 Test (org.junit.jupiter.api.Test)18 NlsString (org.apache.calcite.util.NlsString)17 DingoTableScan (io.dingodb.calcite.rel.DingoTableScan)13 SqlParseException (org.apache.calcite.sql.parser.SqlParseException)11 SqlToRelConverter (org.apache.calcite.sql2rel.SqlToRelConverter)11 LogicalProject (org.apache.calcite.rel.logical.LogicalProject)9 SamzaSqlDslConverterFactory (org.apache.samza.sql.dsl.SamzaSqlDslConverterFactory)8 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)7 RelDataType (org.apache.calcite.rel.type.RelDataType)7 RexBuilder (org.apache.calcite.rex.RexBuilder)7 SqlValidator (org.apache.calcite.sql.validate.SqlValidator)7 DslConverter (org.apache.samza.sql.interfaces.DslConverter)7 Test (org.junit.Test)7 RelOptCluster (org.apache.calcite.plan.RelOptCluster)6 Planner (org.apache.calcite.tools.Planner)6 LogicalFilter (org.apache.calcite.rel.logical.LogicalFilter)5 SqlParser (org.apache.calcite.sql.parser.SqlParser)5