public static boolean isNullableType(Schema schema) {
    if (!schema.getType().equals(Schema.Type.UNION)) {
      return false;
    }

    List<Schema> itemSchemas = schema.getTypes();
    if (itemSchemas.size() < 2) {
      return false;
    }

    for (Schema itemSchema : itemSchemas) {
      if (Schema.Type.NULL.equals(itemSchema.getType())) {
        return true;
      }
    }

    // [null, null] not allowed, so this check is ok.
    return false;
  }
Determine if an Avro schema is of type Union[T, NULL].  Avro supports nullable
types via a union of type T and null.  This is a very common use case.
As such, we want to silently convert it to just T and allow the value to be null.

When a Hive union type is used with AVRO, the schema type becomes
Union[NULL, T1, T2, ...]. The NULL in the union should be silently removed

@return true if type represents Union[T, Null], false otherwise
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java