Class SchemaUtils

java.lang.Object
org.apache.beam.sdk.schemas.SchemaUtils

public class SchemaUtils extends Object
A set of utility functions for schemas.
  • Constructor Details

    • SchemaUtils

      public SchemaUtils()
  • Method Details

    • mergeWideningNullable

      public static Schema mergeWideningNullable(Schema schema1, Schema schema2)
      Given two schema that have matching types, return a nullable-widened schema.

      The schemas must have matching types, except for field names which can differ. The returned schema will contain the field names in the first schema. All field types will be nullable if the corresponding field type is nullable in either of the input schemas.

    • toLogicalBaseType

      public static <InputT, BaseT> BaseT toLogicalBaseType(Schema.LogicalType<InputT,BaseT> logicalType, InputT inputType)
      Returns the base type given a logical type and the input type.

      This function can be used to handle logical types without knowing InputT or BaseT.

    • toLogicalInputType

      public static <BaseT, InputT> InputT toLogicalInputType(Schema.LogicalType<InputT,BaseT> logicalType, BaseT baseType)
      Returns the input type given a logical type and the base type.

      This function can be used to handle logical types without knowing InputT or BaseT.