Class TypeMappingUtils

java.lang.Object
org.apache.flink.table.utils.TypeMappingUtils

@Internal public final class TypeMappingUtils extends Object
Utility methods for dealing with field types in TableSource and TableSink.
  • 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 a TableSchema.
      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 projectedLogicalFields mask.
    • 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 a TableSchema.

      It puts markers (idx < 0) for time attributes extracted from DefinedProctimeAttribute and DefinedRowtimeAttributes

      computePhysicalIndices(List, DataType, Function) should be preferred. The time attribute markers should not be used anymore.

      Parameters:
      tableSource - Used to extract DefinedRowtimeAttributes, DefinedProctimeAttribute and TableSource.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 projectedLogicalFields mask.
    • 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 for TableSource and TableSink.
      Parameters:
      physicalFieldType - physical field type
      logicalFieldType - logical field type
      physicalFieldName - physical field name
      logicalFieldName - logical field name
      isSource - whether it is a source or sink, used for logging.