Class ReturnTypes
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SqlReturnTypeInference
Type-inference strategy for SUM aggregate function inferred from the operand type, and nullable if the call occurs within a "GROUP BY ()" query.static final SqlReturnTypeInference
Type-inference strategy for $SUM0 aggregate function inferred from the operand type.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based).static final SqlReturnTypeInference
Type-inference strategy that returns the type of the first operand, unless it is a DATE, in which case the return type is TIMESTAMP.static final SqlReturnTypeInference
Same asARG0_EXCEPT_DATE
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy that returns the type of the first operand, unless it is an integer type, in which case the return type is DOUBLE.static final SqlReturnTypeInference
Same asARG0_EXCEPT_INTEGER
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based), with nulls always allowed.static final SqlReturnTypeInference
static final SqlReturnTypeInference
static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based).static final SqlReturnTypeInference
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.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is VARYING the type of the first argument.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDECIMAL_SCALE0
with a fallback toARG0
This rule is used for floor, ceiling.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #1 (0-based).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of the operand #1 (0-based).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of operand #2 (0-based).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the type of operand #2 (0-based).static final SqlReturnTypeInference
static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a BIGINT.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a nullable BIGINT.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a BIGINT with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is Boolean.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a nullable Boolean.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is BOOLEAN NOT NULL.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is Boolean, with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is Boolean, with nulls allowed if the type of the operand #0 (0-based) is nullable.static final SqlReturnTypeInference
Type-inference strategy with similar effect toBOOLEAN_NULLABLE
, which is more efficient, but can only be used if all arguments are BOOLEAN.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a Char.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a nullable CHAR(1).static final SqlReturnTypeInference
Type-inference strategy that always returns "COLUMN_LIST".static final SqlReturnTypeInference
static final SqlReturnTypeInference
Type-inference strategy that always returns "CURSOR".static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is DATE.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is nullable DATE.static final SqlReturnTypeInference
static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the decimal modulus of two exact numeric operands where at least one of the operands is a decimal.static final SqlReturnTypeInference
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.static final SqlReturnTypeInference
Same asDECIMAL_PRODUCT
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is the decimal quotient of two exact numeric operands where at least one of the operands is a decimal.static final SqlReturnTypeInference
Same asDECIMAL_QUOTIENT
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy for a call where the first argument is a decimal.static final SqlReturnTypeInference
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.static final SqlReturnTypeInference
Same asDECIMAL_SUM
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is Double.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a nullable Double.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDOUBLE
if both operands are integer types.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is Double with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy for concatenating two string arguments.static final SqlReturnTypeInference
Same asDYADIC_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Same asDYADIC_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
,SqlTypeTransforms.TO_VARYING
.static final SqlReturnTypeInference
Type-inference strategy for theCUME_DIST
andPERCENT_RANK
aggregate functions.static final SqlReturnTypeInference
Type-inference strategy that always returns GEOMETRY.static final SqlReturnTypeInference
Type-inference strategy for Histogram agg support.static final SqlReturnTypeInference
Returns a MAP type.static final SqlReturnTypeInference
Same asIDENTITY_TO_MAP
but returns with nullability if any of the operands is nullable.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is an Integer.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is an Integer with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
.static final SqlReturnTypeInference
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".static final SqlReturnTypeInference
Returns the same type as the multiset carries.static final SqlReturnTypeInference
Returns the element type of a MULTISET, with nullability enforced.static final SqlReturnTypeInference
Same asMULTISET
but returns with nullability if any of the operands is nullable.static final SqlReturnTypeInference
Returns the type of the only column of a multiset.static final SqlReturnTypeInference
Returns a multiset of column #0 of a multiset.static final SqlReturnTypeInference
Returns a multiset of the first column of a multiset.static final SqlReturnTypeInference
Type-inference strategy for String concatenation.static final SqlReturnTypeInference
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NOT_NULLABLE
.static final SqlReturnTypeInference
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
.static final SqlReturnTypeInference
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE_ALL
.static final SqlReturnTypeInference
Type-inference strategy for String concatenation with separator.static final SqlReturnTypeInference
Same asMULTIVALENT_STRING_WITH_SEP_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE_ALL
.static final SqlReturnTypeInference
Same asMULTIVALENT_STRING_WITH_SEP_SUM_PRECISION
and usingSqlTypeTransforms.TO_NOT_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDECIMAL_MOD_NULLABLE
with a fallback toARG1_NULLABLE
These rules are used for modulus.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDECIMAL_SUM_NULLABLE
with a fallback toLEAST_RESTRICTIVE
These rules are used for addition and subtraction.static final SqlReturnTypeInference
static final SqlReturnTypeInference
Same asDECIMAL_PRODUCT_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDECIMAL_PRODUCT_NULLABLE
with a fallback toARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
.static final SqlReturnTypeInference
Same asDECIMAL_QUOTIENT_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call isDECIMAL_QUOTIENT_NULLABLE
with a fallback toARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
.static final SqlReturnTypeInference
Type-inference strategy for theNTILE
,RANK
,DENSE_RANK
, andROW_NUMBER
aggregate functions.static final SqlReturnTypeInference
Returns the field type of a structured type which has only one field.static final SqlReturnTypeInference
Type-inference strategy where the expression is assumed to be registered as aSqlValidatorNamespace
, and therefore the result type of the call is the type of that namespace.static final SqlReturnTypeInference
Same asDECIMAL_SUM_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is TIME(0).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is nullable TIME(0).static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is TIMESTAMP.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is TIMESTAMP WITH LOCAL TIME ZONE.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is nullable TIMESTAMP WITH LOCAL TIME ZONE.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is nullable TIMESTAMP.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is TIMESTAMP WITH TIME ZONE.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a TINYINT.static final SqlReturnTypeInference
Type-inference strategy whereby the result type of a call is a TINYINT with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Returns an ARRAY type.static final SqlReturnTypeInference
Returns the element type of an ARRAY or MULTISET.static final SqlReturnTypeInference
static final SqlReturnTypeInference
static final SqlReturnTypeInference
Returns a MAP type.static final SqlReturnTypeInference
Returns a ARRAY type.static final SqlReturnTypeInference
static final SqlReturnTypeInference
Returns a ARRAY type.static final SqlReturnTypeInference
static final SqlReturnTypeInference
Returns a ARRAY type.static final SqlReturnTypeInference
static final SqlReturnTypeInference
Returns a MULTISET type.static final SqlReturnTypeInference
Returns a ROW type.static final SqlReturnTypeInference
Type-inference strategy that always returns "VARBINARY".static final SqlReturnTypeInference
Type-inference strategy that always returns "VARBINARY" with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR".static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR(2000)".static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR(2000)" with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR(4)".static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR(4)" with nulls allowed if any of the operands allow nulls.static final SqlReturnTypeInference
Type-inference strategy that always returns "VARCHAR" with nulls allowed if any of the operands allow nulls. -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlReturnTypeInference
andThen
(UnaryOperator<SqlOperatorBinding> bindingTransform, SqlReturnTypeInference typeInference) Returns a return-type inference that first transforms a binding and then applies an inference.static SqlTypeTransformCascade
cascade
(SqlReturnTypeInference rule, SqlTypeTransform... transforms) Creates a return-type inference that applies a rule then a sequence of transforms.static SqlReturnTypeInferenceChain
chain
(SqlReturnTypeInference... rules) Creates a return-type inference that applies a rule then a sequence of rules, returning the first non-null result.static ExplicitReturnTypeInference
explicit
(RelDataType type) Creates an inference rule which returns a copy of a given data type.static ExplicitReturnTypeInference
explicit
(RelProtoDataType protoType) static ExplicitReturnTypeInference
explicit
(SqlTypeName typeName) Creates an inference rule which returns a type with no precision or scale, such asDATE
.static ExplicitReturnTypeInference
explicit
(SqlTypeName typeName, int precision) Creates an inference rule which returns a type with precision but no scale, such asVARCHAR(100)
.static SqlCall
stripOrderBy
(SqlCall call) static SqlOperatorBinding
stripOrderBy
(SqlOperatorBinding operatorBinding) Converts a binding ofFOO(x, y ORDER BY z)
orFOO(x, y ORDER BY z SEPARATOR s)
to a binding ofFOO(x, y)
.static SqlCall
stripSeparator
(SqlCall call)
-
Field Details
-
ARG0
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based). -
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
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_NULLABLE_IF_ARG0_NULLABLE
Type-inference strategy whereby the result type of a call is the type of the operand #0 (0-based). If the operand #0 (0-based) is nullable, the returned type will also be nullable. -
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_INTERVAL
-
ARG0_INTERVAL_NULLABLE
-
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
Type-inference strategy whereby the result type of a call is the type of the operand #1 (0-based). -
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
Type-inference strategy whereby the result type of a call is the type of operand #2 (0-based). -
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
Type-inference strategy whereby the result type of a call is Boolean. -
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_IF_ARG0_NULLABLE
Type-inference strategy whereby the result type of a call is Boolean, with nulls allowed if the type of the operand #0 (0-based) is nullable. -
BOOLEAN_NULLABLE_OPTIMIZED
Type-inference strategy with similar effect toBOOLEAN_NULLABLE
, which is more efficient, but can only be used if all arguments are BOOLEAN. -
BOOLEAN_FORCE_NULLABLE
Type-inference strategy whereby the result type of a call is a nullable Boolean. -
BOOLEAN_NOT_NULL
Type-inference strategy whereby the result type of a call is BOOLEAN NOT NULL. -
DATE
Type-inference strategy whereby the result type of a call is DATE. -
DATE_NULLABLE
Type-inference strategy whereby the result type of a call is nullable DATE. -
ARG0_EXCEPT_DATE
Type-inference strategy that returns the type of the first operand, unless it is a DATE, in which case the return type is TIMESTAMP. Supports cases such as [CALCITE-5757] Incorrect return type for BigQuery TRUNC functions . -
ARG0_EXCEPT_DATE_NULLABLE
Same asARG0_EXCEPT_DATE
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
. -
TIME
Type-inference strategy whereby the result type of a call is TIME(0). -
TIME_NULLABLE
Type-inference strategy whereby the result type of a call is nullable TIME(0). -
TIMESTAMP
Type-inference strategy whereby the result type of a call is TIMESTAMP. -
TIMESTAMP_NULLABLE
Type-inference strategy whereby the result type of a call is nullable TIMESTAMP. -
TIMESTAMP_LTZ
Type-inference strategy whereby the result type of a call is TIMESTAMP WITH LOCAL TIME ZONE. -
TIMESTAMP_TZ
Type-inference strategy whereby the result type of a call is TIMESTAMP WITH TIME ZONE. -
TIMESTAMP_LTZ_NULLABLE
Type-inference strategy whereby the result type of a call is nullable TIMESTAMP WITH LOCAL TIME ZONE. -
DOUBLE
Type-inference strategy whereby the result type of a call is Double. -
DOUBLE_NULLABLE
Type-inference strategy whereby the result type of a call is Double with nulls allowed if any of the operands allow nulls. -
DOUBLE_FORCE_NULLABLE
Type-inference strategy whereby the result type of a call is a nullable Double. -
CHAR
Type-inference strategy whereby the result type of a call is a Char. -
CHAR_FORCE_NULLABLE
Type-inference strategy whereby the result type of a call is a nullable CHAR(1). -
TINYINT
Type-inference strategy whereby the result type of a call is a TINYINT. -
TINYINT_NULLABLE
Type-inference strategy whereby the result type of a call is a TINYINT with nulls allowed if any of the operands allow nulls. -
INTEGER
Type-inference strategy whereby the result type of a call is an Integer. -
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
Type-inference strategy whereby the result type of a call is a BIGINT. -
BIGINT_FORCE_NULLABLE
Type-inference strategy whereby the result type of a call is a nullable BIGINT. -
BIGINT_NULLABLE
Type-inference strategy whereby the result type of a call is a BIGINT with nulls allowed if any of the operands allow nulls. -
VARCHAR_4
Type-inference strategy that always returns "VARCHAR(4)". -
VARCHAR_4_NULLABLE
Type-inference strategy that always returns "VARCHAR(4)" with nulls allowed if any of the operands allow nulls. -
VARCHAR_2000
Type-inference strategy that always returns "VARCHAR(2000)". -
VARCHAR_2000_NULLABLE
Type-inference strategy that always returns "VARCHAR(2000)" with nulls allowed if any of the operands allow nulls. -
VARCHAR
Type-inference strategy that always returns "VARCHAR". -
VARCHAR_NULLABLE
Type-inference strategy that always returns "VARCHAR" with nulls allowed if any of the operands allow nulls. -
VARBINARY
Type-inference strategy that always returns "VARBINARY". -
VARBINARY_NULLABLE
Type-inference strategy that always returns "VARBINARY" with nulls allowed if any of the operands allow nulls. -
HISTOGRAM
Type-inference strategy for Histogram agg support. -
CURSOR
Type-inference strategy that always returns "CURSOR". -
COLUMN_LIST
Type-inference strategy that always returns "COLUMN_LIST". -
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:
-
ARG0_EXCEPT_INTEGER
Type-inference strategy that returns the type of the first operand, unless it is an integer type, in which case the return type is DOUBLE. -
ARG0_EXCEPT_INTEGER_NULLABLE
Same asARG0_EXCEPT_INTEGER
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
. -
MULTISET
Returns the same type as the multiset carries. The multiset type returned is the least restrictive of the call's multiset operands -
TO_COLLECTION_ELEMENT
Returns the element type of an ARRAY or MULTISET.For example, given
INTEGER ARRAY or MULTISET ARRAY
, returnsINTEGER
. -
TO_COLLECTION_ELEMENT_NULLABLE
-
TO_COLLECTION_ELEMENT_FORCE_NULLABLE
-
TO_MULTISET
Returns a MULTISET type.For example, given
INTEGER
, returnsINTEGER MULTISET
. -
MULTISET_ELEMENT_FORCE_NULLABLE
Returns the element type of a MULTISET, with nullability enforced. -
MULTISET_NULLABLE
Same asMULTISET
but returns with nullability if any of the operands is nullable. -
MULTISET_PROJECT_ONLY
Returns the type of the only column of a multiset.For example, given
RECORD(x INTEGER) MULTISET
, returnsINTEGER MULTISET
. -
TO_ARRAY
Returns an ARRAY type.For example, given
INTEGER
, returnsINTEGER ARRAY
. -
TO_MAP
Returns a MAP type.For example, given
Record(f0: INTEGER, f1: DATE)
, returns(INTEGER, DATE) MAP
. -
IDENTITY_TO_MAP
Returns a MAP type.For example, given
STRING
, returns(STRING, STRING) MAP
. -
IDENTITY_TO_MAP_NULLABLE
Same asIDENTITY_TO_MAP
but returns with nullability if any of the operands is nullable. -
TO_ROW
Returns a ROW type.For example, given
(INTEGER, DATE) MAP
, returnsRecord(f0: INTEGER, f1: DATE)
. -
TO_MAP_ENTRIES
Returns a ARRAY type.For example, given
(INTEGER, DATE) MAP
, returnsRecord(f0: INTEGER, f1: DATE) ARRAY
. -
TO_MAP_ENTRIES_NULLABLE
-
TO_MAP_KEYS
Returns a ARRAY type.For example, given
(INTEGER, DATE) MAP
, returnsINTEGER ARRAY
. -
TO_MAP_KEYS_NULLABLE
-
TO_MAP_VALUES
Returns a ARRAY type.For example, given
(INTEGER, DATE) MAP
, returnsDATE ARRAY
. -
TO_MAP_VALUES_NULLABLE
-
GEOMETRY
Type-inference strategy that always returns GEOMETRY. -
INTEGER_QUOTIENT_NULLABLE
Type-inference strategy whereby the result type of a call isARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
. These rules are used for integer division. -
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
Type-inference strategy whereby the result type of a call isDECIMAL_SCALE0
with a fallback toARG0
This rule is used for floor, ceiling. -
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_PRODUCT_NULLABLE
Same asDECIMAL_PRODUCT
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
. -
PRODUCT_FORCE_NULLABLE
Same asDECIMAL_PRODUCT_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
. Also handles multiplication for integers, not just decimals. -
PRODUCT_NULLABLE
Type-inference strategy whereby the result type of a call isDECIMAL_PRODUCT_NULLABLE
with a fallback toARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
. These rules are used for multiplication. -
DECIMAL_QUOTIENT
Type-inference strategy whereby the result type of a call is the decimal quotient of two exact numeric operands where at least one of the operands is a decimal. -
DECIMAL_QUOTIENT_NULLABLE
Same asDECIMAL_QUOTIENT
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
. -
DOUBLE_IF_INTEGERS
Type-inference strategy whereby the result type of a call isDOUBLE
if both operands are integer types. -
QUOTIENT_FORCE_NULLABLE
Same asDECIMAL_QUOTIENT_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
. Also handles multiplication for integers, not just decimals. -
QUOTIENT_NULLABLE
Type-inference strategy whereby the result type of a call isDECIMAL_QUOTIENT_NULLABLE
with a fallback toARG0_INTERVAL_NULLABLE
andLEAST_RESTRICTIVE
. These rules are used for division. -
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. -
DECIMAL_SUM_NULLABLE
Same asDECIMAL_SUM
but returns with nullability if any of the operands is nullable by usingSqlTypeTransforms.TO_NULLABLE
. -
SUM_FORCE_NULLABLE
Same asDECIMAL_SUM_NULLABLE
but returns with nullability if any of the operands is nullable or the operation results in overflow by usingSqlTypeTransforms.FORCE_NULLABLE
. Also handles addition for integers, not just decimals. -
NULLABLE_SUM
Type-inference strategy whereby the result type of a call isDECIMAL_SUM_NULLABLE
with a fallback toLEAST_RESTRICTIVE
These rules are used for addition and subtraction. -
DECIMAL_MOD
-
DECIMAL_MOD_NULLABLE
Type-inference strategy whereby the result type of a call is the decimal modulus of two exact numeric operands where at least one of the operands is a decimal. -
NULLABLE_MOD
Type-inference strategy whereby the result type of a call isDECIMAL_MOD_NULLABLE
with a fallback toARG1_NULLABLE
These rules are used for modulus. -
DYADIC_STRING_SUM_PRECISION
Type-inference strategy for concatenating two string arguments. 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
-
MULTIVALENT_STRING_SUM_PRECISION
Type-inference strategy for String concatenation. Result is varying if either input is; otherwise fixed. For example,concat(cast('a' as varchar(2)), cast('b' as varchar(3)),cast('c' as varchar(2))) returns varchar(7).
concat(cast('a' as varchar), cast('b' as varchar(2)), cast('c' as varchar(2))) returns varchar.
concat(cast('a' as varchar(65535)), cast('b' as varchar(2)), cast('c' as varchar(2))) returns varchar.
-
MULTIVALENT_STRING_WITH_SEP_SUM_PRECISION
Type-inference strategy for String concatenation with separator. The precision of separator should be calculated during combining. Result is varying if either input is; otherwise fixed.For example:
concat_ws(',', cast('a' as varchar(2), cast('b' as varchar(3)), cast('c' as varchar(2)))
returnsvarchar(9)
;concat_ws(',', cast('a' as varchar), cast('b' as varchar(2)), cast('c' as varchar(2)))
returnsvarchar
;concat_ws(',', cast('a' as varchar(65535)), cast('b' as varchar(2)), cast('c' as varchar(2)))
returnsvarchar
.
-
MULTIVALENT_STRING_SUM_PRECISION_NULLABLE
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
. -
MULTIVALENT_STRING_SUM_PRECISION_NOT_NULLABLE
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NOT_NULLABLE
. -
MULTIVALENT_STRING_WITH_SEP_SUM_PRECISION_NOT_NULLABLE
Same asMULTIVALENT_STRING_WITH_SEP_SUM_PRECISION
and usingSqlTypeTransforms.TO_NOT_NULLABLE
. -
MULTIVALENT_STRING_WITH_SEP_SUM_PRECISION_ARG0_NULLABLE
Same asMULTIVALENT_STRING_WITH_SEP_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE_ALL
. -
MULTIVALENT_STRING_SUM_PRECISION_NULLABLE_ALL
Same asMULTIVALENT_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE_ALL
. -
DYADIC_STRING_SUM_PRECISION_NULLABLE_VARYING
Same asDYADIC_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
,SqlTypeTransforms.TO_VARYING
. -
DYADIC_STRING_SUM_PRECISION_NULLABLE
Same asDYADIC_STRING_SUM_PRECISION
and usingSqlTypeTransforms.TO_NULLABLE
. -
SCOPE
Type-inference strategy where the expression is assumed to be registered as aSqlValidatorNamespace
, and therefore the result type of the call is the type of that namespace. -
MULTISET_PROJECT0
Returns a multiset of column #0 of a multiset. For example, givenRECORD(x INTEGER, y DATE) MULTISET
, returnsINTEGER MULTISET
. -
MULTISET_RECORD
Returns a multiset of the first column of a multiset. For example, givenINTEGER MULTISET
, returnsRECORD(x INTEGER) MULTISET
. -
RECORD_TO_SCALAR
Returns the field type of a structured type which has only one field. For example, givenRECORD(x INTEGER)
returnsINTEGER
. -
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
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
Type-inference strategy for theCUME_DIST
andPERCENT_RANK
aggregate functions. -
RANK
Type-inference strategy for theNTILE
,RANK
,DENSE_RANK
, andROW_NUMBER
aggregate functions. -
AVG_AGG_FUNCTION
-
COVAR_REGR_FUNCTION
-
PERCENTILE_DISC_CONT
-
-
Method Details
-
chain
Creates a return-type inference that applies a rule then a sequence of rules, returning the first non-null result. -
cascade
public static SqlTypeTransformCascade cascade(SqlReturnTypeInference rule, SqlTypeTransform... transforms) Creates a return-type inference that applies a rule then a sequence of transforms. -
explicit
-
explicit
Creates an inference rule which returns a copy of a given data type. -
explicit
Creates an inference rule which returns a type with no precision or scale, such asDATE
. -
explicit
Creates an inference rule which returns a type with precision but no scale, such asVARCHAR(100)
. -
andThen
public static SqlReturnTypeInference andThen(UnaryOperator<SqlOperatorBinding> bindingTransform, SqlReturnTypeInference typeInference) Returns a return-type inference that first transforms a binding and then applies an inference.stripOrderBy(org.apache.calcite.sql.SqlOperatorBinding)
is an example ofbindingTransform
. -
stripOrderBy
Converts a binding ofFOO(x, y ORDER BY z)
orFOO(x, y ORDER BY z SEPARATOR s)
to a binding ofFOO(x, y)
. Used forSTRING_AGG
andGROUP_CONCAT
. -
stripOrderBy
-
stripSeparator
-