Search in sources :

Example 31 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 testTransfer.

@Test
public void testTransfer() throws SqlParseException {
    String sql = "insert into test1 select id as id1, id as id2, id as id3, name, amount from test";
    RelRoot relRoot = parse(sql);
    Assert.relNode(relRoot.rel).isA(LogicalTableModify.class).convention(Convention.NONE).singleInput().isA(LogicalProject.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) Test(org.junit.jupiter.api.Test)

Example 32 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 testFullScan.

@Test
public void testFullScan() throws SqlParseException {
    String sql = "select * 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 33 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 testAggregate.

@Test
public void testAggregate() throws SqlParseException {
    String sql = "select count(*) from test";
    RelRoot relRoot = parse(sql);
    Assert.relNode(relRoot.rel).isA(LogicalAggregate.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 34 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 testInsertValues.

@Test
public void testInsertValues() throws SqlParseException {
    String sql = "insert into test values(1, 'Alice', 1.0)";
    RelRoot relRoot = parse(sql);
    LogicalValues values = (LogicalValues) Assert.relNode(relRoot.rel).isA(LogicalTableModify.class).convention(Convention.NONE).prop("operation", TableModify.Operation.INSERT).singleInput().isA(LogicalValues.class).convention(Convention.NONE).getInstance();
    List<? extends List<RexLiteral>> tuples = values.getTuples();
    assertThat(tuples).size().isEqualTo(1);
    List<RexLiteral> tuple = tuples.get(0);
    assertThat(tuple).size().isEqualTo(3);
    log.info("tuple = {}", tuple);
    assertThat(tuple).element(0).hasFieldOrPropertyWithValue("value", BigDecimal.valueOf(1));
    assertThat(tuple).element(1).hasFieldOrPropertyWithValue("value", new NlsString("Alice", DEFAULT_CHARSET.value(), new SqlCollation(SqlCollation.Coercibility.IMPLICIT)));
    assertThat(tuple).element(2).hasFieldOrPropertyWithValue("value", BigDecimal.valueOf(1.0));
}
Also used : RexLiteral(org.apache.calcite.rex.RexLiteral) SqlCollation(org.apache.calcite.sql.SqlCollation) LogicalTableModify(org.apache.calcite.rel.logical.LogicalTableModify) NlsString(org.apache.calcite.util.NlsString) 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 35 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 testAggregateGroup1.

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

Aggregations

RelRoot (org.apache.calcite.rel.RelRoot)77 SqlNode (org.apache.calcite.sql.SqlNode)30 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 SqlParser (org.apache.calcite.sql.parser.SqlParser)6 Planner (org.apache.calcite.tools.Planner)6 LogicalFilter (org.apache.calcite.rel.logical.LogicalFilter)5