@Test public void toTypeSchemaStructTypeNullable() throws Exception { Schema schema = AvroUtils.typeFor(DataTypes.createStructType( Lists.newArrayList( DataTypes.createStructField("field1", DataTypes.StringType, false) )), true); assertEquals("Invalid type", Schema.Type.UNION, schema.getType()); assertEquals("Invalid union size", 2, schema.getTypes().size()); for (Schema s : schema.getTypes()) { assertThat("Invalid union types", s.getType(), anyOf(is(Schema.Type.RECORD), is(Schema.Type.NULL))); if (s.getType().equals(Schema.Type.RECORD)) { assertEquals("Invalid record name", "record0", s.getName()); assertEquals("Invalid field count", 1, s.getFields().size()); assertEquals("Invalid field name", "field1", s.getFields().get(0).name()); assertEquals("Invalid field type", Schema.Type.STRING, s.getFields().get(0).schema().getType()); } } }
public static Schema typeFor(DataType dataType) { return typeFor(dataType, true); }
AvroUtils { public static Schema typeFor(DataType dataType) { return typeFor(dataType, true); } }
AvroUtils { public static Schema typeFor(DataType dataType) { return typeFor(dataType, true); }  }
AvroUtils { public static Schema typeFor(DataType dataType) { return typeFor(dataType, true); }  static Schema schemaFor(StructType structType); static Schema schemaFor(StructType structType, String record, String namespace); static Schema typeFor(DataType dataType); static Schema typeFor(DataType dataType, boolean isOptional); static StructType structTypeFor(Schema schema); static DataType dataTypeFor(Schema schemaType); }
AvroUtils { public static Schema typeFor(DataType dataType) { return typeFor(dataType, true); }  static Schema schemaFor(StructType structType); static Schema schemaFor(StructType structType, String record, String namespace); static Schema typeFor(DataType dataType); static Schema typeFor(DataType dataType, boolean isOptional); static StructType structTypeFor(Schema schema); static DataType dataTypeFor(Schema schemaType);  }