@Override public int size() { return type.getFieldCount(); } },
@Override public int size() { return type.getFieldCount(); } },
/** 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); }
@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); }
/** 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); }