use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testAggregateGroupingWithFilterFails.
@Test
public void testAggregateGroupingWithFilterFails() {
final RelBuilder builder = RelBuilder.create(config().build());
try {
RelNode root = builder.scan("EMP").aggregate(builder.groupKey(6, 7), builder.aggregateCall(SqlStdOperatorTable.GROUPING, false, false, builder.literal(true), "g", builder.field("DEPTNO"))).build();
fail("expected error, got " + root);
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("FILTER not allowed"));
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode in project calcite by apache.
the class RelBuilderTest method testDistinctAlready.
@Test
public void testDistinctAlready() {
// DEPT is already distinct
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("DEPT").distinct().build();
final String expected = "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 testScanFilterEquals.
@Test
public void testScanFilterEquals() {
// Equivalent SQL:
// SELECT *
// FROM emp
// WHERE deptno = 20
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").filter(builder.equals(builder.field("DEPTNO"), builder.literal(20))).build();
final String expected = "LogicalFilter(condition=[=($7, 20)])\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 testScanFilterTriviallyFalse.
@Test
public void testScanFilterTriviallyFalse() {
// Equivalent SQL:
// SELECT *
// FROM emp
// WHERE 1 = 2
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.scan("EMP").filter(builder.equals(builder.literal(1), builder.literal(2))).build();
assertThat(root, hasTree("LogicalValues(tuples=[[]])\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 testValuesNullable.
/**
* Tests creating Values with some field names and some values null.
*/
@Test
public void testValuesNullable() {
// Equivalent SQL:
// VALUES (null, 1, 'abc'), (false, null, 'longer string')
final RelBuilder builder = RelBuilder.create(config().build());
RelNode root = builder.values(new String[] { "a", null, "c" }, null, 1, "abc", false, null, "longer string").build();
final String expected = "LogicalValues(tuples=[[{ null, 1, 'abc' }, { false, null, 'longer string' }]])\n";
assertThat(root, hasTree(expected));
final String expectedType = "RecordType(BOOLEAN a, INTEGER expr$1, CHAR(13) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\" NOT NULL c) NOT NULL";
assertThat(root.getRowType().getFullTypeString(), is(expectedType));
}
Aggregations