use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class PigRelBuilderTest method testScan.
@Test
public void testScan() {
// Equivalent SQL:
// SELECT *
// FROM emp
final PigRelBuilder builder = PigRelBuilder.create(config().build());
final RelNode root = builder.scan("EMP").build();
assertThat(str(root), is("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 PigRelBuilderTest method testGroup2.
@Test
public void testGroup2() {
// Equivalent to Pig Latin:
// r = GROUP e BY deptno, d BY deptno;
final PigRelBuilder builder = PigRelBuilder.create(config().build());
final RelNode root = builder.scan("EMP").scan("DEPT").group(null, null, -1, builder.groupKey("DEPTNO").alias("e"), builder.groupKey("DEPTNO").alias("d")).build();
final String plan = "LogicalJoin(condition=[=($0, $2)], joinType=[inner])\n" + " LogicalAggregate(group=[{0}], EMP=[COLLECT($8)])\n" + " LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], $f8=[ROW($0, $1, $2, $3, $4, $5, $6, $7)])\n" + " LogicalTableScan(table=[[scott, EMP]])\n LogicalAggregate(group=[{0}], DEPT=[COLLECT($3)])\n" + " LogicalProject(DEPTNO=[$0], DNAME=[$1], LOC=[$2], $f3=[ROW($0, $1, $2)])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(str(root), is(plan));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class PigRelBuilderTest method testFilter.
@Test
public void testFilter() {
// Syntax:
// FILTER name BY expr
// Example:
// output_var = FILTER input_var BY (field1 is not null);
final PigRelBuilder builder = PigRelBuilder.create(config().build());
final RelNode root = builder.load("EMP.csv", null, null).filter(builder.isNotNull(builder.field("MGR"))).build();
final String plan = "LogicalFilter(condition=[IS NOT NULL($3)])\n" + " LogicalTableScan(table=[[scott, EMP]])\n";
assertThat(str(root), is(plan));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testProject2.
/**
* Tests each method that creates a scalar expression.
*/
@Test
public void testProject2() {
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").project(builder.field("DEPTNO"), builder.cast(builder.field(6), SqlTypeName.SMALLINT), builder.or(builder.equals(builder.field("DEPTNO"), builder.literal(20)), builder.and(builder.literal(null), builder.equals(builder.field("DEPTNO"), builder.literal(10)), builder.and(builder.isNull(builder.field(6)), builder.not(builder.isNotNull(builder.field(7))))), builder.equals(builder.field("DEPTNO"), builder.literal(20)), builder.equals(builder.field("DEPTNO"), builder.literal(30))), builder.alias(builder.isNull(builder.field(2)), "n2"), builder.alias(builder.isNotNull(builder.field(3)), "nn2"), builder.literal(20), builder.field(6), builder.alias(builder.field(6), "C")).build();
final String expected = "" + "LogicalProject(DEPTNO=[$7], COMM=[CAST($6):SMALLINT NOT NULL]," + " $f2=[OR(=($7, 20), AND(null, =($7, 10), IS NULL($6)," + " IS NULL($7)), =($7, 30))], n2=[IS NULL($2)]," + " nn2=[IS NOT NULL($3)], $f5=[20], COMM0=[$6], C=[$6])\n" + " LogicalTableScan(table=[[scott, EMP]])\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 testJoinCartesian.
@Test
public void testJoinCartesian() {
// Equivalent SQL:
// SELECT * emp CROSS JOIN dept
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").scan("DEPT").join(JoinRelType.INNER).build();
final String expected = "LogicalJoin(condition=[true], joinType=[inner])\n" + " LogicalTableScan(table=[[scott, EMP]])\n" + " LogicalTableScan(table=[[scott, DEPT]])\n";
assertThat(root, hasTree(expected));
}
Aggregations