use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project calcite by apache.
the class SqlTypeFactoryTest method testLeastRestrictiveWithNull.
@Test
public void testLeastRestrictiveWithNull() {
Fixture f = new Fixture();
RelDataType leastRestrictive = f.typeFactory.leastRestrictive(Lists.newArrayList(f.sqlNull, f.sqlNull));
assertThat(leastRestrictive.getSqlTypeName(), is(SqlTypeName.NULL));
assertThat(leastRestrictive.isNullable(), is(true));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project calcite by apache.
the class SqlTypeFactoryTest method testLeastRestrictiveWithAny.
@Test
public void testLeastRestrictiveWithAny() {
Fixture f = new Fixture();
RelDataType leastRestrictive = f.typeFactory.leastRestrictive(Lists.newArrayList(f.sqlBigInt, f.sqlAny));
assertThat(leastRestrictive.getSqlTypeName(), is(SqlTypeName.ANY));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project calcite by apache.
the class SqlCreateTable method execute.
public void execute(CalcitePrepare.Context context) {
final List<String> path = context.getDefaultSchemaPath();
CalciteSchema schema = context.getRootSchema();
for (String p : path) {
schema = schema.getSubSchema(p, true);
}
final JavaTypeFactory typeFactory = new JavaTypeFactoryImpl();
final RelDataTypeFactory.Builder builder = typeFactory.builder();
for (Pair<SqlIdentifier, SqlDataTypeSpec> pair : nameTypes()) {
builder.add(pair.left.getSimple(), pair.right.deriveType(typeFactory, true));
}
final RelDataType rowType = builder.build();
schema.add(name.getSimple(), new MutableArrayTable(name.getSimple(), RelDataTypeImpl.proto(rowType)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project calcite by apache.
the class JavaTypeFactoryExtImpl method createStructType.
/**
* See <a href="http://stackoverflow.com/questions/16966629/what-is-the-difference-between-getfields-and-getdeclaredfields-in-java-reflectio">
* the difference between fields and declared fields</a>.
*/
@Override
public RelDataType createStructType(Class type) {
final List<RelDataTypeField> list = new ArrayList<>();
for (Field field : type.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
// FIXME: watch out for recursion
final Type fieldType = field.getType();
list.add(new RelDataTypeFieldImpl(field.getName(), list.size(), createType(fieldType)));
}
}
return canonize(new JavaRecordType(list, type));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project calcite by apache.
the class PhysTypeImpl method field.
public PhysType field(int ordinal) {
final RelDataTypeField field = rowType.getFieldList().get(ordinal);
final RelDataType type = field.getType();
return PhysTypeImpl.of(typeFactory, toStruct(type), format, false);
}
Aggregations