Class Schema

java.lang.Object
org.apache.beam.sdk.schemas.Schema
All Implemented Interfaces:
Serializable

public class Schema extends Object implements Serializable
Schema describes the fields in Row.
See Also:
  • Constructor Details

  • Method Details

    • builder

      public static Schema.Builder builder()
    • of

      public static Schema of(Schema.Field... fields)
    • sorted

      public Schema sorted()
      Returns an identical Schema with lexicographically sorted fields. Recursively sorts nested fields.
    • withOptions

      public Schema withOptions(Schema.Options options)
      Returns a copy of the Schema with the options set.
    • withOptions

      public Schema withOptions(Schema.Options.Builder optionsBuilder)
      Returns a copy of the Schema with the options set.
    • setUUID

      public void setUUID(UUID uuid)
      Set this schema's UUID. All schemas with the same UUID must be guaranteed to be identical.
    • getEncodingPositions

      public Map<String,Integer> getEncodingPositions()
      Gets the encoding positions for this schema.
    • isEncodingPositionsOverridden

      public boolean isEncodingPositionsOverridden()
      Returns whether encoding positions have been explicitly overridden.
    • setEncodingPositions

      public void setEncodingPositions(Map<String,Integer> encodingPositions)
      Sets the encoding positions for this schema.
    • getUUID

      public @Nullable UUID getUUID()
      Get this schema's UUID.
    • equals

      public boolean equals(@Nullable Object o)
      Returns true if two Schemas have the same fields in the same order.
      Overrides:
      equals in class Object
    • typesEqual

      public boolean typesEqual(Schema other)
      Returns true if two schemas are equal ignoring field names and descriptions.
    • equivalent

      public boolean equivalent(Schema other)
      Returns true if two Schemas have the same fields, but possibly in different orders.
    • assignableTo

      public boolean assignableTo(Schema other)
      Returns true if this Schema can be assigned to another Schema. *
    • assignableToIgnoreNullable

      public boolean assignableToIgnoreNullable(Schema other)
      Returns true if this Schema can be assigned to another Schema, ignoring nullable. *
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getFields

      public List<Schema.Field> getFields()
    • toSchema

      public static Collector<Schema.Field,List<Schema.Field>,Schema> toSchema()
      Collects a stream of Schema.Fields into a Schema.
    • getFieldNames

      public List<@NonNull String> getFieldNames()
      Return the list of all field names.
    • getField

      public Schema.Field getField(int index)
      Return a field by index.
    • getField

      public Schema.Field getField(String name)
    • indexOf

      public int indexOf(String fieldName)
      Find the index of a given field.
    • hasField

      public boolean hasField(String fieldName)
      Returns true if fieldName exists in the schema, false otherwise.
    • nameOf

      public String nameOf(int fieldIndex)
      Return the name of field by index.
    • getFieldCount

      public int getFieldCount()
      Return the count of fields.
    • getOptions

      public Schema.Options getOptions()
    • toSnakeCase

      public Schema toSnakeCase()
      Recursively converts all field names to `snake_case`.
    • toCamelCase

      public Schema toCamelCase()
      Recursively converts all field names to `lowerCamelCase`.