Package org.apache.flink.table.utils
Class TypeMappingUtils
java.lang.Object
org.apache.flink.table.utils.TypeMappingUtils
Utility methods for dealing with field types in
TableSource and TableSink.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckPhysicalLogicalTypeCompatible(LogicalType physicalFieldType, LogicalType logicalFieldType, String physicalFieldName, String logicalFieldName, boolean isSource) Checks whether the given physical field type and logical field type are compatible at the edges of the table ecosystem.static int[]computePhysicalIndices(List<TableColumn> logicalColumns, DataType physicalType, Function<String, String> nameRemapping) Computes indices of physical fields corresponding to the selected logical fields of aTableSchema.static int[]computePhysicalIndicesOrTimeAttributeMarkers(TableSource<?> tableSource, List<TableColumn> logicalColumns, boolean streamMarkers, Function<String, String> nameRemapping) Computes indices of physical fields corresponding to the selected logical fields of aTableSchema.
-
Method Details
-
computePhysicalIndices
public static int[] computePhysicalIndices(List<TableColumn> logicalColumns, DataType physicalType, Function<String, String> nameRemapping) Computes indices of physical fields corresponding to the selected logical fields of aTableSchema.- Parameters:
logicalColumns- Logical columns that describe the physical type.physicalType- Physical type to retrieve indices from.nameRemapping- Additional remapping of a logical to a physical field name. TimestampExtractor works with logical names, but accesses physical fields- Returns:
- Physical indices of logical fields selected with
projectedLogicalFieldsmask.
-
computePhysicalIndicesOrTimeAttributeMarkers
public static int[] computePhysicalIndicesOrTimeAttributeMarkers(TableSource<?> tableSource, List<TableColumn> logicalColumns, boolean streamMarkers, Function<String, String> nameRemapping) Computes indices of physical fields corresponding to the selected logical fields of aTableSchema.It puts markers (idx < 0) for time attributes extracted from
DefinedProctimeAttributeandDefinedRowtimeAttributescomputePhysicalIndices(List, DataType, Function)should be preferred. The time attribute markers should not be used anymore.- Parameters:
tableSource- Used to extractDefinedRowtimeAttributes,DefinedProctimeAttributeandTableSource.getProducedDataType().logicalColumns- Logical columns that describe the physical type.streamMarkers- If true puts stream markers otherwise puts batch markers.nameRemapping- Additional remapping of a logical to a physical field name. TimestampExtractor works with logical names, but accesses physical fields- Returns:
- Physical indices of logical fields selected with
projectedLogicalFieldsmask.
-
checkPhysicalLogicalTypeCompatible
public static void checkPhysicalLogicalTypeCompatible(LogicalType physicalFieldType, LogicalType logicalFieldType, String physicalFieldName, String logicalFieldName, boolean isSource) Checks whether the given physical field type and logical field type are compatible at the edges of the table ecosystem. Types are still compatible if the physical type is a legacy decimal type (converted from Types#BIG_DEC) and the logical type is DECIMAL(38, 18). This is to support legacy TypeInformation forTableSourceandTableSink.- Parameters:
physicalFieldType- physical field typelogicalFieldType- logical field typephysicalFieldName- physical field namelogicalFieldName- logical field nameisSource- whether it is a source or sink, used for logging.
-