Class LogicalType

    • Constructor Detail

      • LogicalType

        public LogicalType​(boolean isNullable,
                           LogicalTypeRoot typeRoot)
    • Method Detail

      • isNullable

        public boolean isNullable()
        Returns whether a value of this type can be null.
      • getTypeRoot

        public LogicalTypeRoot getTypeRoot()
        Returns the root of this type. It is an essential description without additional parameters.
      • is

        public boolean is​(LogicalTypeRoot typeRoot)
        Returns whether the root of the type equals to the typeRoot or not.
        Parameters:
        typeRoot - The root type to check against for equality
      • isAnyOf

        public boolean isAnyOf​(LogicalTypeRoot... typeRoots)
        Returns whether the root of the type equals to at least on of the typeRoots or not.
        Parameters:
        typeRoots - The root types to check against for equality
      • isAnyOf

        public boolean isAnyOf​(LogicalTypeFamily... typeFamilies)
        Returns whether the root of the type is part of at least one family of the typeFamily or not.
        Parameters:
        typeFamilies - The families to check against for equality
      • is

        public boolean is​(LogicalTypeFamily family)
        Returns whether the family type of the type equals to the family or not.
        Parameters:
        family - The family type to check against for equality
      • copy

        public abstract LogicalType copy​(boolean isNullable)
        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

        public final LogicalType copy()
        Returns a deep copy of this type. It requires an implementation of copy(boolean).
        Returns:
        a deep copy
      • asSerializableString

        public abstract String asSerializableString()
        Returns a string that fully serializes this instance. The serialized string can be used for transmitting or persisting a type.

        See LogicalTypeParser for the reverse operation.

        Returns:
        detailed string for transmission or persistence
      • asSummaryString

        public String 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

        public abstract boolean supportsInputConversion​(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. 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.Long or long can be used as input for BIGINT independent 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:
        getDefaultConversion()
      • supportsOutputConversion

        public abstract boolean supportsOutputConversion​(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. 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.Long or long can be used as output for BIGINT if the type is not nullable. If the type is nullable, only java.lang.Long can 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()
      • getDefaultConversion

        public abstract Class<?> 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.Long is the default input and output for BIGINT.

        Returns:
        default class to represent values of this logical type
        See Also:
        supportsInputConversion(Class), supportsOutputConversion(Class)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • withNullability

        protected String withNullability​(String format,
                                         Object... params)
      • conversionSet

        protected static Set<String> conversionSet​(String... elements)