public interface RelDataTypeSystem
Provides behaviors concerning type limits and behaviors. For example, in the default system, a DECIMAL can have maximum precision 19, but Hive overrides to 38.
The default implementation is DEFAULT.
| Modifier and Type | Field and Description |
|---|---|
static RelDataTypeSystem |
DEFAULT
Default type system.
|
| Modifier and Type | Method and Description |
|---|---|
RelDataType |
deriveAvgAggType(RelDataTypeFactory typeFactory,
RelDataType argumentType)
Returns the return type of a call to the
AVG, STDDEV or
VAR aggregate functions, inferred from its argument type. |
RelDataType |
deriveCovarType(RelDataTypeFactory typeFactory,
RelDataType arg0Type,
RelDataType arg1Type)
Returns the return type of a call to the
COVAR aggregate function,
inferred from its argument types. |
default @Nullable RelDataType |
deriveDecimalDivideType(RelDataTypeFactory typeFactory,
RelDataType type1,
RelDataType type2)
Infers the return type of a decimal division.
|
default @Nullable RelDataType |
deriveDecimalModType(RelDataTypeFactory typeFactory,
RelDataType type1,
RelDataType type2)
Infers the return type of a decimal modulus operation.
|
default @Nullable RelDataType |
deriveDecimalMultiplyType(RelDataTypeFactory typeFactory,
RelDataType type1,
RelDataType type2)
Infers the return type of a decimal multiplication.
|
default @Nullable RelDataType |
deriveDecimalPlusType(RelDataTypeFactory typeFactory,
RelDataType type1,
RelDataType type2)
Infers the return type of a decimal addition.
|
RelDataType |
deriveFractionalRankType(RelDataTypeFactory typeFactory)
Returns the return type of the
CUME_DIST and PERCENT_RANK
aggregate functions. |
RelDataType |
deriveRankType(RelDataTypeFactory typeFactory)
Returns the return type of the
NTILE, RANK,
DENSE_RANK, and ROW_NUMBER aggregate functions. |
RelDataType |
deriveSumType(RelDataTypeFactory typeFactory,
RelDataType argumentType)
Returns the return type of a call to the
SUM aggregate function,
inferred from its argument type. |
int |
getDefaultPrecision(SqlTypeName typeName)
Returns default precision for this type if supported, otherwise -1 if
precision is either unsupported or must be specified explicitly.
|
@Nullable String |
getLiteral(SqlTypeName typeName,
boolean isPrefix)
Returns the LITERAL string for the type, either PREFIX/SUFFIX.
|
int |
getMaxNumericPrecision()
Returns the maximum precision of a NUMERIC or DECIMAL type.
|
int |
getMaxNumericScale()
Returns the maximum scale of a NUMERIC or DECIMAL type.
|
int |
getMaxPrecision(SqlTypeName typeName)
Returns the maximum precision (or length) allowed for this type, or -1 if
precision/length are not applicable for this type.
|
int |
getMaxScale(SqlTypeName typeName)
Returns the maximum scale of a given type.
|
int |
getNumTypeRadix(SqlTypeName typeName)
Returns the numeric type radix, typically 2 or 10.
|
boolean |
isAutoincrement(SqlTypeName typeName)
Returns whether the type can be auto increment.
|
boolean |
isCaseSensitive(SqlTypeName typeName)
Returns whether the type is case sensitive.
|
boolean |
isSchemaCaseSensitive()
Whether two record types are considered distinct if their field names
are the same but in different cases.
|
boolean |
shouldConvertRaggedUnionTypesToVarying()
Whether the least restrictive type of a number of CHAR types of different
lengths should be a VARCHAR type.
|
default boolean |
shouldUseDoubleMultiplication(RelDataTypeFactory typeFactory,
RelDataType type1,
RelDataType type2)
Returns whether a decimal multiplication should be implemented by casting
arguments to double values.
|
static final RelDataTypeSystem DEFAULT
int getMaxScale(SqlTypeName typeName)
int getDefaultPrecision(SqlTypeName typeName)
int getMaxPrecision(SqlTypeName typeName)
int getMaxNumericScale()
int getMaxNumericPrecision()
@Nullable String getLiteral(SqlTypeName typeName, boolean isPrefix)
boolean isCaseSensitive(SqlTypeName typeName)
boolean isAutoincrement(SqlTypeName typeName)
int getNumTypeRadix(SqlTypeName typeName)
RelDataType deriveSumType(RelDataTypeFactory typeFactory, RelDataType argumentType)
SUM aggregate function,
inferred from its argument type.RelDataType deriveAvgAggType(RelDataTypeFactory typeFactory, RelDataType argumentType)
AVG, STDDEV or
VAR aggregate functions, inferred from its argument type.RelDataType deriveCovarType(RelDataTypeFactory typeFactory, RelDataType arg0Type, RelDataType arg1Type)
COVAR aggregate function,
inferred from its argument types.RelDataType deriveFractionalRankType(RelDataTypeFactory typeFactory)
CUME_DIST and PERCENT_RANK
aggregate functions.RelDataType deriveRankType(RelDataTypeFactory typeFactory)
NTILE, RANK,
DENSE_RANK, and ROW_NUMBER aggregate functions.boolean isSchemaCaseSensitive()
boolean shouldConvertRaggedUnionTypesToVarying()
default boolean shouldUseDoubleMultiplication(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2)
Pre-condition: createDecimalProduct(type1, type2) != null
default @Nullable RelDataType deriveDecimalPlusType(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2)
Rules:
typeFactory - TypeFactory used to create output typetype1 - Type of the first operandtype2 - Type of the second operandSQL:2003 Part 2 Section 6.26default @Nullable RelDataType deriveDecimalMultiplyType(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2)
The default implementation is SQL:2003 compliant.
Rules:
p and s are capped at their maximum values
typeFactory - TypeFactory used to create output typetype1 - Type of the first operandtype2 - Type of the second operandSQL:2003 Part 2 Section 6.26default @Nullable RelDataType deriveDecimalDivideType(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2)
The default implementation is SQL:2003 compliant.
Rules:
typeFactory - TypeFactory used to create output typetype1 - Type of the first operandtype2 - Type of the second operandSQL:2003 Part 2 Section 6.26default @Nullable RelDataType deriveDecimalModType(RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2)
The default implementation is SQL:2003 compliant: the declared type of the result is the declared type of the second operand (expression divisor).
typeFactory - TypeFactory used to create output typetype1 - Type of the first operandtype2 - Type of the second operandSQL:2003 Part 2 Section 6.27
Rules:
- 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
- Let d be the number of whole digits in the result
- Then the result type is a decimal with:
- s = max(s1, s2)
- p = min(p1 - s1, p2 - s2) + max(s1, s2)
- p and s are capped at their maximum values
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.