OmniSciDB
a5dc49c757
|
Public Member Functions | |
HeavyDBTypeCoercion (RelDataTypeFactory typeFactory, SqlValidator validator) | |
int | calculateTypeCoercionScore (SqlCallBinding callBinding, ExtTableFunction udtf) |
RelDataType | getWiderTypeForTwo (RelDataType type1, RelDataType type2, boolean stringPromotion) |
boolean | extTableFunctionTypeCoercion (SqlCallBinding callBinding, ExtTableFunction udtf) |
Protected Member Functions | |
boolean | needToCast (SqlValidatorScope scope, SqlNode node, RelDataType toType) |
Private Member Functions | |
int | calculateScoreForCursorOperand (SqlNode cursorOperand, int index, SqlValidatorScope scope, ExtTableFunction udtf) |
void | coerceCursorType (SqlValidatorScope scope, SqlCall call, int index, SqlNode cursorOperand, ExtTableFunction udtf) |
void | updateValidatedType (List< RelDataTypeField > typeList, SqlSelect selectNode, int operandIndex) |
int | getScoreForTypes (RelDataType targetType, RelDataType originalType, boolean isCursorArgument) |
void | coerceBinOpOperand (SqlBasicCall binOp, RelDataType targetType, SqlValidatorScope scope) |
boolean | shouldCoerceBinOpOperand (SqlNode op, RelDataType targetType, SqlValidatorScope scope) |
Definition at line 31 of file HeavyDBTypeCoercion.java.
|
inline |
Definition at line 32 of file HeavyDBTypeCoercion.java.
|
inlineprivate |
Calculates a type coercion score for a single CURSOR() operand. CURSORS need special logic because their underlying types are composite types of one or multiple columns.
Definition at line 103 of file HeavyDBTypeCoercion.java.
References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Cursor, com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.getArgTypes(), com.mapd.calcite.parser.HeavyDBTypeCoercion.getScoreForTypes(), com.mapd.calcite.parser.HeavyDBTypeCoercion.getWiderTypeForTwo(), score, and com.mapd.calcite.parser.HeavyDBTypeCoercion.shouldCoerceBinOpOperand().
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateTypeCoercionScore().
|
inline |
Calculates a type coercion score for a given call to a User-Defined Table Function, assuming the call is bound to overload . This is used to perform overload resolution and type checking while considering implicit type coercions are performed (automatic casting of input scalar/columnar arguments).
Definition at line 42 of file HeavyDBTypeCoercion.java.
References com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateScoreForCursorOperand(), com.mapd.calcite.parser.HeavyDBTypeCoercion.getScoreForTypes(), com.mapd.calcite.parser.HeavyDBTypeCoercion.getWiderTypeForTwo(), and score.
Referenced by com.mapd.calcite.parser.ExtTableFunctionTypeChecker.checkOperandTypes().
|
inlineprivate |
Coerces operands of a binary operator to the given .
Definition at line 497 of file HeavyDBTypeCoercion.java.
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceCursorType().
|
inlineprivate |
Definition at line 304 of file HeavyDBTypeCoercion.java.
References com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceBinOpOperand(), com.mapd.calcite.parser.HeavyDBTypeCoercion.getWiderTypeForTwo(), com.mapd.calcite.parser.HeavyDBTypeCoercion.shouldCoerceBinOpOperand(), and com.mapd.calcite.parser.HeavyDBTypeCoercion.updateValidatedType().
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.extTableFunctionTypeCoercion().
|
inline |
After a call has been bound to the lowest cost overload, this method performs any necessary coercion of input scalar/columnar arguments in the call.
Definition at line 258 of file HeavyDBTypeCoercion.java.
References com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceCursorType(), and com.mapd.calcite.parser.HeavyDBTypeCoercion.getWiderTypeForTwo().
|
inlineprivate |
Returns a coercion score between an input type and a target type to be casted to. Currently we consider cursor arguments as 100x more expensive than scalar arguments. We also consider a 10x cost to cast from integer to floating point types, to favor overloads that conserve precision.
multiplier
Definition at line 464 of file HeavyDBTypeCoercion.java.
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateScoreForCursorOperand(), and com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateTypeCoercionScore().
|
inline |
We overload this to add a few additional useful rules that Calcite does not implement by default: TIMESTAMP() of lower precision should be castable to higher precision DOUBLE should be the widest type for {FLOAT, REAL, DOUBLE}
Definition at line 240 of file HeavyDBTypeCoercion.java.
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateScoreForCursorOperand(), com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateTypeCoercionScore(), com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceCursorType(), and com.mapd.calcite.parser.HeavyDBTypeCoercion.extTableFunctionTypeCoercion().
|
inlineprotected |
We overload this specifically to REMOVE a rule Calcite uses: Calcite will not cast types in the NUMERIC type family across each other. Therefore, with Calcite's default rules, we would not cast INTEGER columns to BIGINT, or FLOAT to DOUBLE.
Definition at line 403 of file HeavyDBTypeCoercion.java.
|
inlineprivate |
Determines if a binary operator's operands need to be coerced explicitly. Calcite considers the output of some binary operators involving literals as a wider type. As a consequence, some operations such as FLOAT + <float_literal> are type-inferenced to DOUBLE, and will typecheck against UDTFs that accept DOUBLE columns. However, these parameters are still sent to the backend as FLOATs. This method identifies these occurrences, so that they can be casted explicitly.
Definition at line 514 of file HeavyDBTypeCoercion.java.
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.calculateScoreForCursorOperand(), and com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceCursorType().
|
inlineprivate |
Updates validated type for CURSOR SqlNodes that had their underlying types coerced.
Definition at line 441 of file HeavyDBTypeCoercion.java.
Referenced by com.mapd.calcite.parser.HeavyDBTypeCoercion.coerceCursorType().