Class LogicalType
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArrayType,BigIntType,BinaryType,BooleanType,CharType,DateType,DayTimeIntervalType,DecimalType,DoubleType,FloatType,IntType,LegacyTypeInformationType,LocalZonedTimestampType,MapType,MultisetType,NullType,RawType,RowType,SmallIntType,SymbolType,TimestampType,TimeType,TinyIntType,TypeInformationRawType,UnresolvedUserDefinedType,UserDefinedType,VarBinaryType,VarCharType,YearMonthIntervalType,ZonedTimestampType
The definition of a logical type is similar to the SQL standard's "data type" terminology but also contains information about the nullability of a value for efficient handling of scalar expressions.
Subclasses of this class define characteristics of built-in or user-defined types. Every logical type must support nullability.
Instances of this class describe the fully parameterized, immutable type with additional information such as numeric precision or expected length.
Contracts how logical types relate to other types are defined by LogicalTypeCasts and
LogicalTypeMerging.
NOTE: A logical type is just a description of a type, a planner or runtime might not support every type in every logical precision yet!
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <R> Raccept(LogicalTypeVisitor<R> visitor) abstract StringReturns a string that fully serializes this instance.Returns a string that summarizes this type for printing to a console.conversionSet(String... elements) final LogicalTypecopy()Returns a deep copy of this type.abstract LogicalTypecopy(boolean isNullable) Returns a deep copy of this type with possibly different nullability.booleanabstract List<LogicalType>abstract Class<?>Returns the default conversion class.Returns the root of this type.inthashCode()booleanis(LogicalTypeFamily family) Returns whether the family type of the type equals to thefamilyor not.booleanis(LogicalTypeRoot typeRoot) Returns whether the root of the type equals to thetypeRootor not.booleanisAnyOf(LogicalTypeFamily... typeFamilies) Returns whether the root of the type is part of at least one family of thetypeFamilyor not.booleanisAnyOf(LogicalTypeRoot... typeRoots) Returns whether the root of the type equals to at least on of thetypeRootsor not.booleanReturns whether a value of this type can benull.abstract booleansupportsInputConversion(Class<?> clazz) Returns whether an instance of the given class can be represented as a value of this logical type when entering the table ecosystem.abstract booleansupportsOutputConversion(Class<?> clazz) Returns whether a value of this logical type can be represented as an instance of the given class when leaving the table ecosystem.toString()protected StringwithNullability(String format, Object... params)
-
Constructor Details
-
LogicalType
-
-
Method Details
-
isNullable
public boolean isNullable()Returns whether a value of this type can benull. -
getTypeRoot
Returns the root of this type. It is an essential description without additional parameters. -
is
Returns whether the root of the type equals to thetypeRootor not.- Parameters:
typeRoot- The root type to check against for equality
-
isAnyOf
Returns whether the root of the type equals to at least on of thetypeRootsor not.- Parameters:
typeRoots- The root types to check against for equality
-
isAnyOf
Returns whether the root of the type is part of at least one family of thetypeFamilyor not.- Parameters:
typeFamilies- The families to check against for equality
-
is
Returns whether the family type of the type equals to thefamilyor not.- Parameters:
family- The family type to check against for equality
-
copy
Returns a deep copy of this type with possibly different nullability.- Parameters:
isNullable- the intended nullability of the copied type- Returns:
- a deep copy
-
copy
Returns a deep copy of this type. It requires an implementation ofcopy(boolean).- Returns:
- a deep copy
-
asSerializableString
Returns a string that fully serializes this instance. The serialized string can be used for transmitting or persisting a type.See
LogicalTypeParserfor the reverse operation.- Returns:
- detailed string for transmission or persistence
-
asSummaryString
Returns a string that summarizes this type for printing to a console. An implementation might shorten long names or skips very specific properties.Use
asSerializableString()for a type string that fully serializes this instance.- Returns:
- summary string of this type for debugging purposes
-
supportsInputConversion
Returns whether an instance of the given class can be represented as a value of this logical type when entering the table ecosystem. This method helps for the interoperability between JVM-based languages and the relational type system.A supported conversion directly maps an input class to a logical type without loss of precision or type widening.
For example,
java.lang.Longorlongcan be used as input forBIGINTindependent of the set nullability.- Parameters:
clazz- input class to be converted into this logical type- Returns:
- flag that indicates if instances of this class can be used as input into the table ecosystem
- See Also:
-
supportsOutputConversion
Returns whether a value of this logical type can be represented as an instance of the given class when leaving the table ecosystem. This method helps for the interoperability between JVM-based languages and the relational type system.A supported conversion directly maps a logical type to an output class without loss of precision or type widening.
For example,
java.lang.Longorlongcan be used as output forBIGINTif the type is not nullable. If the type is nullable, onlyjava.lang.Longcan represent this.- Parameters:
clazz- output class to be converted from this logical type- Returns:
- flag that indicates if instances of this class can be used as output from the table ecosystem
- See Also:
-
getDefaultConversion
Returns the default conversion class. A value of this logical type is expected to be an instance of the given class when entering or is represented as an instance of the given class when leaving the table ecosystem if no other conversion has been specified.For example,
java.lang.Longis the default input and output forBIGINT.- Returns:
- default class to represent values of this logical type
- See Also:
-
getChildren
-
accept
-
toString
-
equals
-
hashCode
public int hashCode() -
withNullability
-
conversionSet
-