Class LogicalTypeChecks
- java.lang.Object
-
- org.apache.flink.table.types.logical.utils.LogicalTypeChecks
-
@Internal public final class LogicalTypeChecks extends Object
Utilities for checkingLogicalTypeand avoiding a lot of type casting and repetitive work.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanBeTimeAttributeType(LogicalType logicalType)static intgetDayPrecision(LogicalType logicalType)static intgetFieldCount(LogicalType logicalType)Returns the field count of row and structured types.static List<String>getFieldNames(LogicalType logicalType)Returns the field names of row and structured types.static List<LogicalType>getFieldTypes(LogicalType logicalType)Returns the field types of row and structured types.static intgetFractionalPrecision(LogicalType logicalType)static intgetLength(LogicalType logicalType)static intgetPrecision(LogicalType logicalType)Returns the precision of all types that define a precision implicitly or explicitly.static intgetScale(LogicalType logicalType)Returns the scale of all types that define a scale implicitly or explicitly.static intgetYearPrecision(LogicalType logicalType)static booleanhasDayPrecision(LogicalType logicalType, int yearPrecision)static booleanhasFractionalPrecision(LogicalType logicalType, int fractionalPrecision)static booleanhasLegacyTypes(LogicalType logicalType)Checks whether a (possibly nested) logical type containsLegacyTypeInformationTypeorTypeInformationRawType.static booleanhasLength(LogicalType logicalType, int length)static booleanhasNested(LogicalType logicalType, java.util.function.Predicate<LogicalType> predicate)Checks whether a (possibly nested) logical type fulfills the given predicate.static booleanhasPrecision(LogicalType logicalType, int precision)Checks the precision of a type that defines a precision implicitly or explicitly.static booleanhasScale(LogicalType logicalType, int scale)Checks the scale of all types that define a scale implicitly or explicitly.static booleanhasWellDefinedString(LogicalType logicalType)Checks whether the givenLogicalTypehas a well-defined string representation when callingObject.toString()on the internal data structure.static booleanhasYearPrecision(LogicalType logicalType, int yearPrecision)static booleanisCompositeType(LogicalType logicalType)Checks if the given type is a composite type.static booleanisProctimeAttribute(LogicalType logicalType)static booleanisRowtimeAttribute(LogicalType logicalType)static booleanisSingleFieldInterval(LogicalType logicalType)static booleanisTimeAttribute(LogicalType logicalType)
-
-
-
Method Detail
-
hasNested
public static boolean hasNested(LogicalType logicalType, java.util.function.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 containsLegacyTypeInformationTypeorTypeInformationRawType.
-
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 givenLogicalTypehas a well-defined string representation when callingObject.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.
-
-