parquet-cli/src/main/java/org/apache/parquet/cli/util/Schemas.java
private static Schema nullableForDefault(Schema schema) {
    if (schema.getType() == Schema.Type.NULL) {
      return schema;
    }

    if (schema.getType() != Schema.Type.UNION) {
      return Schema.createUnion(ImmutableList.of(NULL, schema));
    }

    if (schema.getTypes().get(0).getType() == Schema.Type.NULL) {
      return schema;
    }

    List<Schema> types = Lists.newArrayList();
    types.add(NULL);
    for (Schema type : schema.getTypes()) {
      if (type.getType() != Schema.Type.NULL) {
        types.add(type);
      }
    }

    return Schema.createUnion(types);
  }
private static Schema nullableForDefault(Schema schema) {
    if (schema.getType() == Schema.Type.NULL) {
      return schema;
    }

    if (schema.getType() != Schema.Type.UNION) {
      return Schema.createUnion(ImmutableList.of(NULL, schema));
    }

    if (schema.getTypes().get(0).getType() == Schema.Type.NULL) {
      return schema;
    }

    List<Schema> types = Lists.newArrayList();
    types.add(NULL);
    for (Schema type : schema.getTypes()) {
      if (type.getType() != Schema.Type.NULL) {
        types.add(type);
      }
    }

    return Schema.createUnion(types);
  }
private static Schema nullableForDefault ( Schema schema ) { if ( schema . getType ( ) == Schema . Type . NULL ) { return schema ; } if ( schema . getType ( ) != Schema . Type . UNION ) { return Schema . createUnion ( ImmutableList . of ( NULL , schema ) ) ; } if ( schema . getTypes ( ) . get ( 0 ) . getType ( ) == Schema . Type . NULL ) { return schema ; } List < Schema > types = Lists . newArrayList ( ) ; types . add ( NULL ) ; for ( Schema type : schema . getTypes ( ) ) { if ( type . getType ( ) != Schema . Type . NULL ) { types . add ( type ) ; } } return Schema . createUnion ( types ) ; }
Returns a union {@link Schema} of NULL and the given {@code schema}.
<p>
A NULL schema is always the first type in the union so that a null default
value can be set.

@param schema a {@code Schema}
@return a union of null and the given schema
Returns a union { @link Schema } of NULL and the given { @code schema } . <p > A NULL schema is always the first type in the union so that a null default value can be set .