AvroSchemaConverter { public RelDataType convert() { if (rootSchema.getType() != Schema.Type.RECORD) { throw new RuntimeException( String.format("Type: %s is unsupported at this level; Only Record type of supported at top level!", rootSchema.getType())); } return convertRecord(rootSchema, true); } AvroSchemaConverter(RelDataTypeFactory relDataTypeFactory, Schema schema); RelDataType convert();  }
@Test public void testSimpleAvroRecord(){ RelDataTypeFactory relDataTypeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); AvroSchemaConverter schemaConverter = new AvroSchemaConverter(relDataTypeFactory, simpleRecord); RelDataType relDataType = schemaConverter.convert(); Assert.assertEquals(SqlTypeName.VARCHAR, relDataType.getField("name", false, false).getType().getSqlTypeName()); Assert.assertEquals(SqlTypeName.INTEGER, relDataType.getField("favorite_number", false, false).getType().getSqlTypeName()); Assert.assertTrue(relDataType.getField("favorite_number", false, false).getType().isNullable()); Assert.assertEquals(SqlTypeName.VARCHAR, relDataType.getField("favorite_color", false, false).getType().getSqlTypeName()); Assert.assertTrue(relDataType.getField("favorite_color", false, false).getType().isNullable()); }