Class FieldInfoUtils

java.lang.Object
org.apache.flink.table.typeutils.FieldInfoUtils

@Internal public class FieldInfoUtils extends Object
Utility methods for extracting names and indices of fields from different TypeInformations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Describes fields' names, indices and DataTypes extracted from a TypeInformation and possibly transformed via Expression application.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    getFieldIndices(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType)
    Returns field indexes for a given TypeInformation.
    static <A> String[]
    getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType)
    Returns field names for a given TypeInformation.
    static <A> String[]
    getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, List<String> existingNames)
    Returns field names for a given TypeInformation.
    getFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType)
    Returns a FieldInfoUtils.TypeInfoSchema for a given TypeInformation.
    getFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, org.apache.flink.table.expressions.Expression[] expressions)
    Returns a FieldInfoUtils.TypeInfoSchema for a given TypeInformation.
    static org.apache.flink.api.common.typeinfo.TypeInformation<?>[]
    getFieldTypes(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType)
    Returns field types for a given TypeInformation.
    static <A> void
    validateInputTypeInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> typeInfo)
    Validate if class represented by the typeInfo is static and globally accessible.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getFieldsInfo

      public static <A> FieldInfoUtils.TypeInfoSchema getFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType)
      Returns a FieldInfoUtils.TypeInfoSchema for a given TypeInformation.
      Type Parameters:
      A - The type of the TypeInformation.
      Parameters:
      inputType - The TypeInformation to extract the mapping from.
      Returns:
      A description of the input that enables creation of a TableSchema.
      See Also:
    • getFieldsInfo

      public static <A> FieldInfoUtils.TypeInfoSchema getFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, org.apache.flink.table.expressions.Expression[] expressions)
      Returns a FieldInfoUtils.TypeInfoSchema for a given TypeInformation. It gives control of the process of mapping TypeInformation to TableSchema (via FieldInfoUtils.TypeInfoSchema).

      Possible operations via the expressions include:

      • specifying rowtime & proctime attributes via .proctime, .rowtime
        • There can be only a single rowtime and/or a single proctime attribute
        • Proctime attribute can only be appended to the end of the expression list
        • Rowtime attribute can replace an input field if the input field has a compatible type. See TimestampType.
      • renaming fields by position (this cannot be mixed with referencing by name)
      • renaming & projecting fields by name (this cannot be mixed with referencing by position)
      Type Parameters:
      A - The type of the TypeInformation.
      Parameters:
      inputType - The TypeInformation to extract the mapping from.
      expressions - Expressions to apply while extracting the mapping.
      Returns:
      A description of the input that enables creation of a TableSchema.
      See Also:
    • getFieldNames

      public static <A> String[] getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType)
      Returns field names for a given TypeInformation.
      Type Parameters:
      A - The type of the TypeInformation.
      Parameters:
      inputType - The TypeInformation extract the field names.
      Returns:
      An array holding the field names
    • getFieldNames

      public static <A> String[] getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, List<String> existingNames)
      Returns field names for a given TypeInformation. If the input TypeInformation is not a composite type, the result field name should not exist in the existingNames.
      Type Parameters:
      A - The type of the TypeInformation.
      Parameters:
      inputType - The TypeInformation extract the field names.
      existingNames - The existing field names for non-composite types that can not be used.
      Returns:
      An array holding the field names
    • validateInputTypeInfo

      public static <A> void validateInputTypeInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> typeInfo)
      Validate if class represented by the typeInfo is static and globally accessible.
      Parameters:
      typeInfo - type to check
      Throws:
      org.apache.flink.table.api.ValidationException - if type does not meet these criteria
    • getFieldIndices

      public static int[] getFieldIndices(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType)
      Returns field indexes for a given TypeInformation.
      Parameters:
      inputType - The TypeInformation extract the field positions from.
      Returns:
      An array holding the field positions
    • getFieldTypes

      public static org.apache.flink.api.common.typeinfo.TypeInformation<?>[] getFieldTypes(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType)
      Returns field types for a given TypeInformation.
      Parameters:
      inputType - The TypeInformation to extract field types from.
      Returns:
      An array holding the field types.