private Schema readUnion(JsonReader reader, Set<String> knownRecords) throws IOException {
    ImmutableList.Builder<Schema> unionSchemas = ImmutableList.builder();
    reader.beginArray();
    while (reader.peek() != JsonToken.END_ARRAY) {
      unionSchemas.add(read(reader, knownRecords));
    }
    reader.endArray();
    return Schema.unionOf(unionSchemas.build());
  }
private Schema readUnion ( JsonReader reader , Set < String > knownRecords ) throws IOException { ImmutableList . Builder < Schema > unionSchemas = ImmutableList . builder ( ) ; reader . beginArray ( ) ; while ( reader . peek ( ) != JsonToken . END_ARRAY ) { unionSchemas . add ( read ( reader , knownRecords ) ) ; } reader . endArray ( ) ; return Schema . unionOf ( unionSchemas . build ( ) ) ; }
Constructs {@link Schema.Type#UNION UNION} type schema from the json input.

@param reader The {@link JsonReader} for streaming json input tokens.
@param knownRecords Set of record name already encountered during the reading.
@return A {@link Schema} of type {@link Schema.Type#UNION UNION}.
@throws java.io.IOException When fails to construct a valid schema from the input.