Package org.apache.flink.table.typeutils
Class FieldInfoUtils
java.lang.Object
org.apache.flink.table.typeutils.FieldInfoUtils
Utility methods for extracting names and indices of fields from different
TypeInformations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDescribes fields' names, indices andDataTypes extracted from aTypeInformationand possibly transformed viaExpressionapplication. -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]getFieldIndices(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType) Returns field indexes for a givenTypeInformation.static <A> String[]getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType) Returns field names for a givenTypeInformation.static <A> String[]getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, List<String> existingNames) Returns field names for a givenTypeInformation.static <A> FieldInfoUtils.TypeInfoSchemagetFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType) Returns aFieldInfoUtils.TypeInfoSchemafor a givenTypeInformation.static <A> FieldInfoUtils.TypeInfoSchemagetFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType, org.apache.flink.table.expressions.Expression[] expressions) Returns aFieldInfoUtils.TypeInfoSchemafor a givenTypeInformation.static org.apache.flink.api.common.typeinfo.TypeInformation<?>[]getFieldTypes(org.apache.flink.api.common.typeinfo.TypeInformation<?> inputType) Returns field types for a givenTypeInformation.static <A> voidvalidateInputTypeInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> typeInfo) Validate if class represented by the typeInfo is static and globally accessible.
-
Method Details
-
getFieldsInfo
public static <A> FieldInfoUtils.TypeInfoSchema getFieldsInfo(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType) Returns aFieldInfoUtils.TypeInfoSchemafor a givenTypeInformation.- 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 aFieldInfoUtils.TypeInfoSchemafor a givenTypeInformation. It gives control of the process of mappingTypeInformationtoTableSchema(viaFieldInfoUtils.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:
- specifying rowtime & proctime attributes via .proctime, .rowtime
-
getFieldNames
public static <A> String[] getFieldNames(org.apache.flink.api.common.typeinfo.TypeInformation<A> inputType) Returns field names for a givenTypeInformation.- 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 givenTypeInformation. If the inputTypeInformationis 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 givenTypeInformation.- 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 givenTypeInformation.- Parameters:
inputType- The TypeInformation to extract field types from.- Returns:
- An array holding the field types.
-