Class ReturnTypes


  • public abstract class ReturnTypes
    extends java.lang.Object
    A collection of return-type inference strategies.
    • Field Detail

      • ARG0

        public static final SqlReturnTypeInference ARG0
        Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based).
      • ARG0_NULLABLE_VARYING

        public static final SqlReturnTypeInference ARG0_NULLABLE_VARYING
        Type-inference strategy whereby the result type of a call is VARYING the type of the first argument. The length returned is the same as length of the first argument. If any of the other operands are nullable the returned type will also be nullable. First Arg must be of string type.
      • ARG0_NULLABLE

        public static final SqlReturnTypeInference ARG0_NULLABLE
        Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based). If any of the other operands are nullable the returned type will also be nullable.
      • ARG0_FORCE_NULLABLE

        public static final SqlReturnTypeInference ARG0_FORCE_NULLABLE
        Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based), with nulls always allowed.
      • ARG0_NULLABLE_IF_EMPTY

        public static final SqlReturnTypeInference ARG0_NULLABLE_IF_EMPTY
        Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based), and nullable if the call occurs within a "GROUP BY ()" query. E.g. in "select sum(1) as s from empty", s may be null.
      • ARG1

        public static final SqlReturnTypeInference ARG1
        Type-inference strategy whereby the result type of a call is the type of the operand #1 (0-based).
      • ARG1_NULLABLE

        public static final SqlReturnTypeInference ARG1_NULLABLE
        Type-inference strategy whereby the result type of a call is the type of the operand #1 (0-based). If any of the other operands are nullable the returned type will also be nullable.
      • ARG2

        public static final SqlReturnTypeInference ARG2
        Type-inference strategy whereby the result type of a call is the type of operand #2 (0-based).
      • ARG2_NULLABLE

        public static final SqlReturnTypeInference ARG2_NULLABLE
        Type-inference strategy whereby the result type of a call is the type of operand #2 (0-based). If any of the other operands are nullable the returned type will also be nullable.
      • BOOLEAN

        public static final SqlReturnTypeInference BOOLEAN
        Type-inference strategy whereby the result type of a call is Boolean.
      • BOOLEAN_NULLABLE

        public static final SqlReturnTypeInference BOOLEAN_NULLABLE
        Type-inference strategy whereby the result type of a call is Boolean, with nulls allowed if any of the operands allow nulls.
      • BOOLEAN_NULLABLE_OPTIMIZED

        public static final SqlReturnTypeInference BOOLEAN_NULLABLE_OPTIMIZED
        Type-inference strategy with similar effect to BOOLEAN_NULLABLE, which is more efficient, but can only be used if all arguments are BOOLEAN.
      • BOOLEAN_FORCE_NULLABLE

        public static final SqlReturnTypeInference BOOLEAN_FORCE_NULLABLE
        Type-inference strategy whereby the result type of a call is a nullable Boolean.
      • BOOLEAN_NOT_NULL

        public static final SqlReturnTypeInference BOOLEAN_NOT_NULL
        Type-inference strategy whereby the result type of a call is Boolean not null.
      • DATE

        public static final SqlReturnTypeInference DATE
        Type-inference strategy whereby the result type of a call is Date.
      • TIME

        public static final SqlReturnTypeInference TIME
        Type-inference strategy whereby the result type of a call is Time(0).
      • TIME_NULLABLE

        public static final SqlReturnTypeInference TIME_NULLABLE
        Type-inference strategy whereby the result type of a call is nullable Time(0).
      • DOUBLE

        public static final SqlReturnTypeInference DOUBLE
        Type-inference strategy whereby the result type of a call is Double.
      • DOUBLE_NULLABLE

        public static final SqlReturnTypeInference DOUBLE_NULLABLE
        Type-inference strategy whereby the result type of a call is Double with nulls allowed if any of the operands allow nulls.
      • INTEGER

        public static final SqlReturnTypeInference INTEGER
        Type-inference strategy whereby the result type of a call is an Integer.
      • INTEGER_NULLABLE

        public static final SqlReturnTypeInference INTEGER_NULLABLE
        Type-inference strategy whereby the result type of a call is an Integer with nulls allowed if any of the operands allow nulls.
      • BIGINT

        public static final SqlReturnTypeInference BIGINT
        Type-inference strategy whereby the result type of a call is a Bigint
      • BIGINT_FORCE_NULLABLE

        public static final SqlReturnTypeInference BIGINT_FORCE_NULLABLE
        Type-inference strategy whereby the result type of a call is a nullable Bigint
      • BIGINT_NULLABLE

        public static final SqlReturnTypeInference BIGINT_NULLABLE
        Type-inference strategy whereby the result type of a call is an Bigint with nulls allowed if any of the operands allow nulls.
      • VARCHAR_2000

        public static final SqlReturnTypeInference VARCHAR_2000
        Type-inference strategy that always returns "VARCHAR(2000)".
      • HISTOGRAM

        public static final SqlReturnTypeInference HISTOGRAM
        Type-inference strategy for Histogram agg support
      • CURSOR

        public static final SqlReturnTypeInference CURSOR
        Type-inference strategy that always returns "CURSOR".
      • COLUMN_LIST

        public static final SqlReturnTypeInference COLUMN_LIST
        Type-inference strategy that always returns "COLUMN_LIST".
      • LEAST_RESTRICTIVE

        public static final SqlReturnTypeInference LEAST_RESTRICTIVE
        Type-inference strategy whereby the result type of a call is using its operands biggest type, using the SQL:1999 rules described in "Data types of results of aggregations". These rules are used in union, except, intersect, case and other places.
        See Also:
        SQL:1999 Part 2 Section 9.3
      • MULTISET

        public static final SqlReturnTypeInference MULTISET
        Returns the same type as the multiset carries. The multiset type returned is the least restrictive of the call's multiset operands
      • TO_MULTISET

        public static final SqlReturnTypeInference TO_MULTISET
        Returns a multiset type.

        For example, given INTEGER, returns INTEGER MULTISET.

      • MULTISET_ELEMENT_NULLABLE

        public static final SqlReturnTypeInference MULTISET_ELEMENT_NULLABLE
        Returns the element type of a multiset
      • MULTISET_NULLABLE

        public static final SqlReturnTypeInference MULTISET_NULLABLE
        Same as MULTISET but returns with nullability if any of the operands is nullable.
      • MULTISET_PROJECT_ONLY

        public static final SqlReturnTypeInference MULTISET_PROJECT_ONLY
        Returns the type of the only column of a multiset.

        For example, given RECORD(x INTEGER) MULTISET, returns INTEGER MULTISET.

      • DECIMAL_SCALE0

        public static final SqlReturnTypeInference DECIMAL_SCALE0
        Type-inference strategy for a call where the first argument is a decimal. The result type of a call is a decimal with a scale of 0, and the same precision and nullability as the first argument.
      • ARG0_OR_EXACT_NO_SCALE

        public static final SqlReturnTypeInference ARG0_OR_EXACT_NO_SCALE
        Type-inference strategy whereby the result type of a call is DECIMAL_SCALE0 with a fallback to ARG0 This rule is used for floor, ceiling.
      • DECIMAL_PRODUCT

        public static final SqlReturnTypeInference DECIMAL_PRODUCT
        Type-inference strategy whereby the result type of a call is the decimal product of two exact numeric operands where at least one of the operands is a decimal.
      • DECIMAL_QUOTIENT

        public static final SqlReturnTypeInference DECIMAL_QUOTIENT
        Type-inference strategy whereby the result type of a call is the decimal product of two exact numeric operands where at least one of the operands is a decimal.
      • DECIMAL_SUM

        public static final SqlReturnTypeInference DECIMAL_SUM
        Type-inference strategy whereby the result type of a call is the decimal sum of two exact numeric operands where at least one of the operands is a decimal. Let p1, s1 be the precision and scale of the first operand Let p2, s2 be the precision and scale of the second operand Let p, s be the precision and scale of the result, Then the result type is a decimal with:
        • s = max(s1, s2)
        • p = max(p1 - s1, p2 - s2) + s + 1

        p and s are capped at their maximum values

        See Also:
        SQL:2003 Part 2 Section 6.26
      • DYADIC_STRING_SUM_PRECISION

        public static final SqlReturnTypeInference DYADIC_STRING_SUM_PRECISION
        Type-inference strategy whereby the result type of a call is
        • the same type as the input types but with the combined length of the two first types
        • if types are of char type the type with the highest coercibility will be used
        • result is varying if either input is; otherwise fixed

        Pre-requisites:

        • input types must be of the same string type
        • types must be comparable without casting
      • SCOPE

        public static final SqlReturnTypeInference SCOPE
        Type-inference strategy where the expression is assumed to be registered as a SqlValidatorNamespace, and therefore the result type of the call is the type of that namespace.
      • MULTISET_PROJECT0

        public static final SqlReturnTypeInference MULTISET_PROJECT0
        Returns a multiset of column #0 of a multiset. For example, given RECORD(x INTEGER, y DATE) MULTISET, returns INTEGER MULTISET.
      • MULTISET_RECORD

        public static final SqlReturnTypeInference MULTISET_RECORD
        Returns a multiset of the first column of a multiset. For example, given INTEGER MULTISET, returns RECORD(x INTEGER) MULTISET.
      • RECORD_TO_SCALAR

        public static final SqlReturnTypeInference RECORD_TO_SCALAR
        Returns the field type of a structured type which has only one field. For example, given RECORD(x INTEGER) returns INTEGER.
      • AGG_SUM

        public static final SqlReturnTypeInference AGG_SUM
        Type-inference strategy for SUM aggregate function inferred from the operand type, and nullable if the call occurs within a "GROUP BY ()" query. E.g. in "select sum(x) as s from empty", s may be null. Also, with the default implementation of RelDataTypeSystem, s has the same type name as x.
      • AGG_SUM_EMPTY_IS_ZERO

        public static final SqlReturnTypeInference AGG_SUM_EMPTY_IS_ZERO
        Type-inference strategy for $SUM0 aggregate function inferred from the operand type. By default the inferred type is identical to the operand type. E.g. in "select $sum0(x) as s from empty", s has the same type as x.
      • FRACTIONAL_RANK

        public static final SqlReturnTypeInference FRACTIONAL_RANK
        Type-inference strategy for the CUME_DIST and PERCENT_RANK aggregate functions.
      • RANK

        public static final SqlReturnTypeInference RANK
        Type-inference strategy for the NTILE, RANK, DENSE_RANK, and ROW_NUMBER aggregate functions.
    • Constructor Detail

      • ReturnTypes

        private ReturnTypes()