Class LogicalTypeChecks

java.lang.Object
org.apache.flink.table.types.logical.utils.LogicalTypeChecks

@Internal public final class LogicalTypeChecks extends Object
Utilities for checking LogicalType and avoiding a lot of type casting and repetitive work.
  • Method Details

    • hasNested

      public static boolean hasNested(LogicalType logicalType, Predicate<LogicalType> predicate)
      Checks whether a (possibly nested) logical type fulfills the given predicate.
    • hasLegacyTypes

      public static boolean hasLegacyTypes(LogicalType logicalType)
      Checks whether a (possibly nested) logical type contains LegacyTypeInformationType or TypeInformationRawType.
    • isTimeAttribute

      public static boolean isTimeAttribute(LogicalType logicalType)
    • isRowtimeAttribute

      public static boolean isRowtimeAttribute(LogicalType logicalType)
    • isProctimeAttribute

      public static boolean isProctimeAttribute(LogicalType logicalType)
    • canBeTimeAttributeType

      public static boolean canBeTimeAttributeType(LogicalType logicalType)
    • isCompositeType

      public static boolean isCompositeType(LogicalType logicalType)
      Checks if the given type is a composite type.

      Use getFieldCount(LogicalType), getFieldNames(LogicalType), getFieldTypes(LogicalType) for unified handling of composite types.

      Parameters:
      logicalType - Logical data type to check
      Returns:
      True if the type is composite type.
    • getLength

      public static int getLength(LogicalType logicalType)
    • hasLength

      public static boolean hasLength(LogicalType logicalType, int length)
    • getPrecision

      public static int getPrecision(LogicalType logicalType)
      Returns the precision of all types that define a precision implicitly or explicitly.
    • hasPrecision

      public static boolean hasPrecision(LogicalType logicalType, int precision)
      Checks the precision of a type that defines a precision implicitly or explicitly.
    • getScale

      public static int getScale(LogicalType logicalType)
      Returns the scale of all types that define a scale implicitly or explicitly.
    • hasScale

      public static boolean hasScale(LogicalType logicalType, int scale)
      Checks the scale of all types that define a scale implicitly or explicitly.
    • getYearPrecision

      public static int getYearPrecision(LogicalType logicalType)
    • hasYearPrecision

      public static boolean hasYearPrecision(LogicalType logicalType, int yearPrecision)
    • getDayPrecision

      public static int getDayPrecision(LogicalType logicalType)
    • hasDayPrecision

      public static boolean hasDayPrecision(LogicalType logicalType, int yearPrecision)
    • getFractionalPrecision

      public static int getFractionalPrecision(LogicalType logicalType)
    • hasFractionalPrecision

      public static boolean hasFractionalPrecision(LogicalType logicalType, int fractionalPrecision)
    • isSingleFieldInterval

      public static boolean isSingleFieldInterval(LogicalType logicalType)
    • getFieldCount

      public static int getFieldCount(LogicalType logicalType)
      Returns the field count of row and structured types. Other types return 1.
    • getFieldNames

      public static List<String> getFieldNames(LogicalType logicalType)
      Returns the field names of row and structured types.
    • getFieldTypes

      public static List<LogicalType> getFieldTypes(LogicalType logicalType)
      Returns the field types of row and structured types.
    • hasWellDefinedString

      public static boolean hasWellDefinedString(LogicalType logicalType)
      Checks whether the given LogicalType has a well-defined string representation when calling Object.toString() on the internal data structure. The string representation would be similar in SQL or in a programming language.

      Note: This method might not be necessary anymore, once we have implemented a utility that can convert any internal data structure to a well-defined string representation.

    • areComparable

      public static boolean areComparable(LogicalType firstType, LogicalType secondType, StructuredType.StructuredComparison requiredComparison)