use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testValuesAllNull.
@Test
public void testValuesAllNull() {
final RelBuilder builder = RelBuilder.create(config().build());
RelDataType rowType = builder.getTypeFactory().builder().add("a", SqlTypeName.BIGINT).add("a", SqlTypeName.VARCHAR, 10).build();
RelNode root = builder.values(rowType, null, null, 1, null).build();
final String expected = "LogicalValues(tuples=[[{ null, null }, { 1, null }]])\n";
assertThat(root, hasTree(expected));
final String expectedType = "RecordType(BIGINT NOT NULL a, VARCHAR(10) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\" NOT NULL a) NOT NULL";
assertThat(root.getRowType().getFullTypeString(), is(expectedType));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testAliasPastTop.
/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-1523">[CALCITE-1523]
* Add RelBuilder field() method to reference aliased relations not on top of
* stack</a>, accessing tables aliased that are not accessible in the top
* RelNode.
*/
@Test
public void testAliasPastTop() {
// Equivalent SQL:
// SELECT *
// FROM emp
// LEFT JOIN dept ON emp.deptno = dept.deptno
// AND emp.empno = 123
// AND dept.deptno IS NOT NULL
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").scan("DEPT").join(JoinRelType.LEFT, builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, "EMP", "DEPTNO"), builder.field(2, "DEPT", "DEPTNO")), builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, "EMP", "EMPNO"), builder.literal(123))).build();
final String expected = "" + "LogicalJoin(condition=[AND(=($7, $8), =($0, 123))], joinType=[left])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(root, hasTree(expected));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testScan.
@Test
public void testScan() {
// Equivalent SQL:
// SELECT *
// FROM emp
final RelNode root = RelBuilder.create(config().build()).scan("EMP").build();
assertThat(root, hasTree("LogicalTableScan(table=[[scott, EMP]])\n"));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testJoin2.
@Test
public void testJoin2() {
// Equivalent SQL:
// SELECT *
// FROM emp
// LEFT JOIN dept ON emp.deptno = dept.deptno
// AND emp.empno = 123
// AND dept.deptno IS NOT NULL
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").scan("DEPT").join(JoinRelType.LEFT, builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, 0, "DEPTNO"), builder.field(2, 1, "DEPTNO")), builder.call(SqlStdOperatorTable.EQUALS, builder.field(2, 0, "EMPNO"), builder.literal(123)), builder.call(SqlStdOperatorTable.IS_NOT_NULL, builder.field(2, 1, "DEPTNO"))).build();
// Note that "dept.deptno IS NOT NULL" has been simplified away.
final String expected = "" + "LogicalJoin(condition=[AND(=($7, $8), =($0, 123))], joinType=[left])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(root, hasTree(expected));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testUnion3.
@Test
public void testUnion3() {
// Equivalent SQL:
// SELECT deptno FROM dept
// UNION ALL
// SELECT empno FROM emp
// UNION ALL
// SELECT deptno FROM emp
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("DEPT").project(builder.field("DEPTNO")).scan("EMP").project(builder.field("EMPNO")).scan("EMP").project(builder.field("DEPTNO")).union(true, 3).build();
final String expected = "" + "LogicalUnion(all=[true])\n" + " LogicalProject(DEPTNO=[$0])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n" + " LogicalProject(EMPNO=[$0])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalProject(DEPTNO=[$7])\n" + " LogicalTableScan(table=[[scott, EMP]])\n";
assertThat(root, hasTree(expected));
}
Aggregations