@Override protected RelDataType deriveRowType() { return new RelRecordType(Lists.<RelDataTypeField>newArrayList()); } }
RelRecordType rec = (RelRecordType) type; RelDataType nodeType = rec.getFieldList().get(0).getType(); nodeType = typeFactory.createTypeWithNullability(nodeType, true); fieldList.add(Pair.of(alias, nodeType));
/** Creates a synthetic Java class whose fields have the same names and * relational types. */ private Type createSyntheticType(RelRecordType type) { final String name = "Record" + type.getFieldCount() + "_" + syntheticTypes.size(); final SyntheticRecordType syntheticType = new SyntheticRecordType(type, name); for (final RelDataTypeField recordField : type.getFieldList()) { final Type javaClass = getJavaClass(recordField.getType()); syntheticType.fields.add( new RecordFieldImpl( syntheticType, recordField.getName(), javaClass, recordField.getType().isNullable() && !Primitive.is(javaClass), Modifier.PUBLIC)); } return register(syntheticType); }
private RelDataType copyRecordType( final RelRecordType type, final boolean ignoreNullable, final boolean nullable) { // REVIEW: angel 18-Aug-2005 dtbug336 // Shouldn't null refer to the nullability of the record type // not the individual field types? // For flattening and outer joins, it is desirable to change // the nullability of the individual fields. return createStructType(type.getStructKind(), new AbstractList<RelDataType>() { @Override public RelDataType get(int index) { RelDataType fieldType = type.getFieldList().get(index).getType(); if (ignoreNullable) { return copyType(fieldType); } else { return createTypeWithNullability(fieldType, nullable); } } @Override public int size() { return type.getFieldCount(); } }, type.getFieldNames()); }
@Test public void testSimpleSchemaConversion() { String streamName = "stream"; SqlSchema sqlSchema = simpleRecordSchemaProvider.getSqlSchema(); RelDataType dataType = relSchemaConverter.convertToRelSchema(sqlSchema); junit.framework.Assert.assertTrue(dataType instanceof RelRecordType); RelRecordType recordType = (RelRecordType) dataType; junit.framework.Assert.assertEquals(recordType.getFieldCount(), SimpleRecord.SCHEMA$.getFields().size()); junit.framework.Assert.assertTrue( recordType.getField("id", true, false).getType().getSqlTypeName() == SqlTypeName.INTEGER); junit.framework.Assert.assertTrue( recordType.getField("name", true, false).getType().getSqlTypeName() == SqlTypeName.VARCHAR); LOG.info("Relational schema " + dataType); }
@Override public int size() { return type.getFieldCount(); } },
/** * Creates a <code>RecordType</code>. This should only be called from a * factory method. */ public RelRecordType(StructKind kind, List<RelDataTypeField> fields) { super(fields); this.kind = Objects.requireNonNull(kind); computeDigest(); }
/** Creates a synthetic Java class whose fields have the same names and * relational types. */ private Type createSyntheticType(RelRecordType type) { final String name = "Record" + type.getFieldCount() + "_" + syntheticTypes.size(); final SyntheticRecordType syntheticType = new SyntheticRecordType(type, name); for (final RelDataTypeField recordField : type.getFieldList()) { final Type javaClass = getJavaClass(recordField.getType()); syntheticType.fields.add( new RecordFieldImpl( syntheticType, recordField.getName(), javaClass, recordField.getType().isNullable() && !Primitive.is(javaClass), Modifier.PUBLIC)); } return register(syntheticType); }
private RelDataType copyRecordType( final RelRecordType type, final boolean ignoreNullable, final boolean nullable) { // REVIEW: angel 18-Aug-2005 dtbug336 // Shouldn't null refer to the nullability of the record type // not the individual field types? // For flattening and outer joins, it is desirable to change // the nullability of the individual fields. return createStructType(type.getStructKind(), new AbstractList<RelDataType>() { @Override public RelDataType get(int index) { RelDataType fieldType = type.getFieldList().get(index).getType(); if (ignoreNullable) { return copyType(fieldType); } else { return createTypeWithNullability(fieldType, nullable); } } @Override public int size() { return type.getFieldCount(); } }, type.getFieldNames()); }
@Override public int size() { return type.getFieldCount(); } },
/** * Creates a <code>RecordType</code>. This should only be called from a * factory method. */ public RelRecordType(StructKind kind, List<RelDataTypeField> fields) { super(fields); this.kind = Objects.requireNonNull(kind); computeDigest(); }
/** * Per {@link Serializable} API. See * {@link RelRecordType#writeReplace()}. */ private Object readResolve() { return new RelRecordType(fields); } }
@Override public RelDataType get(int index) { RelDataType fieldType = type.getFieldList().get(index).getType(); if (ignoreNullable) { return copyType(fieldType); } else { return createTypeWithNullability(fieldType, nullable); } }
/** * Per {@link Serializable} API. See * {@link RelRecordType#writeReplace()}. */ private Object readResolve() { return new RelRecordType(fields); } }
@Override public RelDataType get(int index) { RelDataType fieldType = type.getFieldList().get(index).getType(); if (ignoreNullable) { return copyType(fieldType); } else { return createTypeWithNullability(fieldType, nullable); } }
private RelDataType convertRecordType(Schema schema) { List<RelDataTypeField> relFields = getRelFields(schema.getFields()); return new RelRecordType(relFields); }
RelRecordType rec = (RelRecordType) type; RelDataType nodeType = rec.getFieldList().get(0).getType(); nodeType = typeFactory.createTypeWithNullability(nodeType, true); fieldList.add(Pair.of(alias, nodeType));
private static RelDataType keyToType(@Nonnull Object k) { if (k instanceof RelDataType) { return (RelDataType) k; } @SuppressWarnings("unchecked") final Key key = (Key) k; final ImmutableList.Builder<RelDataTypeField> list = ImmutableList.builder(); for (int i = 0; i < key.names.size(); i++) { list.add( new RelDataTypeFieldImpl( key.names.get(i), i, key.types.get(i))); } return new RelRecordType(key.kind, list.build()); }
RelRecordType rec = (RelRecordType) type; RelDataType nodeType = rec.getFieldList().get(0).getType(); nodeType = typeFactory.createTypeWithNullability(nodeType, true); fieldList.add(Pair.of(alias, nodeType));
private static RelDataType keyToType(@Nonnull Object k) { if (k instanceof RelDataType) { return (RelDataType) k; } @SuppressWarnings("unchecked") final Key key = (Key) k; final ImmutableList.Builder<RelDataTypeField> list = ImmutableList.builder(); for (int i = 0; i < key.names.size(); i++) { list.add( new RelDataTypeFieldImpl( key.names.get(i), i, key.types.get(i))); } return new RelRecordType(key.kind, list.build()); }