private Schema complexSchemaForType ( String fieldPath , Record record , Field field ) throws OnRecordErrorException { Schema simpleSchema = simpleSchemaForType ( fieldPath , record , field ) ; Schema finalSchema = simpleSchema ; if ( getConfig ( ) . avroNullableFields ) { finalSchema = Schema . createUnion ( ImmutableList . of ( Schema . create ( Schema . Type . NULL ) , simpleSchema ) ) ; } JsonNode defaultValue = getDefaultValue ( simpleSchema ) ; if ( defaultValue != null ) { finalSchema . addProp ( "defaultValue" , defaultValue ) ; } return finalSchema ; }
Generates complex schema for given field that will include optional union with null and potentially default value as well . Particularly useful to generate nested structures .