use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.JavaTypeFactoryImpl in project storm by apache.
the class TestCompilerUtils method sqlOverDummyTable.
public static CalciteState sqlOverDummyTable(String sql) throws RelConversionException, ValidationException, SqlParseException {
SchemaPlus schema = Frameworks.createRootSchema(true);
JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
StreamableTable streamableTable = new CompilerUtil.TableBuilderInfo(typeFactory).field("ID", SqlTypeName.INTEGER, new ColumnConstraint.PrimaryKey(SqlMonotonicity.MONOTONIC, SqlParserPos.ZERO)).field("NAME", typeFactory.createType(String.class)).field("ADDR", typeFactory.createType(String.class)).build();
Table table = streamableTable.stream();
schema.add("FOO", table);
schema.add("BAR", table);
schema.add("MYPLUS", ScalarFunctionImpl.create(MyPlus.class, "eval"));
QueryPlanner queryPlanner = new QueryPlanner(schema);
StreamsRel tree = queryPlanner.getPlan(sql);
System.out.println(StormRelUtils.explain(tree, SqlExplainLevel.ALL_ATTRIBUTES));
return new CalciteState(schema, tree);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.JavaTypeFactoryImpl in project calcite by apache.
the class RexTransformerTest method setUp.
@Before
public void setUp() {
typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
rexBuilder = new RexBuilder(typeFactory);
boolRelDataType = typeFactory.createSqlType(SqlTypeName.BOOLEAN);
x = new RexInputRef(0, typeFactory.createTypeWithNullability(boolRelDataType, true));
y = new RexInputRef(1, typeFactory.createTypeWithNullability(boolRelDataType, true));
z = new RexInputRef(2, typeFactory.createTypeWithNullability(boolRelDataType, true));
trueRex = rexBuilder.makeLiteral(true);
falseRex = rexBuilder.makeLiteral(false);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.JavaTypeFactoryImpl in project calcite by apache.
the class SqlLimitsTest method testPrintLimits.
@Test
public void testPrintLimits() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
final List<RelDataType> types = getTypes(new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT));
for (RelDataType type : types) {
pw.println(type.toString());
printLimit(pw, " min - epsilon: ", type, false, SqlTypeName.Limit.OVERFLOW, true);
printLimit(pw, " min: ", type, false, SqlTypeName.Limit.OVERFLOW, false);
printLimit(pw, " zero - delta: ", type, false, SqlTypeName.Limit.UNDERFLOW, false);
printLimit(pw, " zero - delta + epsilon: ", type, false, SqlTypeName.Limit.UNDERFLOW, true);
printLimit(pw, " zero: ", type, false, SqlTypeName.Limit.ZERO, false);
printLimit(pw, " zero + delta - epsilon: ", type, true, SqlTypeName.Limit.UNDERFLOW, true);
printLimit(pw, " zero + delta: ", type, true, SqlTypeName.Limit.UNDERFLOW, false);
printLimit(pw, " max: ", type, true, SqlTypeName.Limit.OVERFLOW, false);
printLimit(pw, " max + epsilon: ", type, true, SqlTypeName.Limit.OVERFLOW, true);
pw.println();
}
pw.flush();
getDiffRepos().assertEquals("output", "${output}", sw.toString());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.JavaTypeFactoryImpl in project calcite by apache.
the class SqlOperatorBindingTest method setUp.
@Before
public void setUp() {
JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
integerDataType = typeFactory.createSqlType(SqlTypeName.INTEGER);
integerType = SqlTypeUtil.convertTypeToSpec(integerDataType);
rexBuilder = new RexBuilder(typeFactory);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.JavaTypeFactoryImpl in project calcite by apache.
the class PermutationTestCase method testProjectPermutation.
@Test
public void testProjectPermutation() {
final RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl();
final RexBuilder builder = new RexBuilder(typeFactory);
final RelDataType doubleType = typeFactory.createSqlType(SqlTypeName.DOUBLE);
// A project with [1, 1] is not a permutation, so should return null
final Permutation perm = Project.getPermutation(2, ImmutableList.of(builder.makeInputRef(doubleType, 1), builder.makeInputRef(doubleType, 1)));
assertThat(perm, nullValue());
// A project with [0, 1, 0] is not a permutation, so should return null
final Permutation perm1 = Project.getPermutation(2, ImmutableList.of(builder.makeInputRef(doubleType, 0), builder.makeInputRef(doubleType, 1), builder.makeInputRef(doubleType, 0)));
assertThat(perm1, nullValue());
// A project of [1, 0] is a valid permutation!
final Permutation perm2 = Project.getPermutation(2, ImmutableList.of(builder.makeInputRef(doubleType, 1), builder.makeInputRef(doubleType, 0)));
assertThat(perm2, is(new Permutation(new int[] { 1, 0 })));
}
Aggregations