basic-lib/src/main/java/com/streamsets/pipeline/stage/processor/schemagen/generators/AvroSchemaGenerator.java
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;
  }
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;
  }
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.
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 .