Class AbstractTypeCoercion

java.lang.Object
org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion
All Implemented Interfaces:
TypeCoercion
Direct Known Subclasses:
TypeCoercionImpl

public abstract class AbstractTypeCoercion extends Object implements TypeCoercion
Base class for all the type coercion rules. If you want to have a custom type coercion rules, inheriting this class is not necessary, but would have some convenient tool methods.

We make tool methods: coerceOperandType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlCall, int, org.apache.calcite.rel.type.RelDataType), coerceColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNodeList, int, org.apache.calcite.rel.type.RelDataType), needToCast(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType), updateInferredType(org.apache.calcite.sql.SqlNode, org.apache.calcite.rel.type.RelDataType), updateInferredColumnType(org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.SqlNode, int, org.apache.calcite.rel.type.RelDataType) all overridable by derived classes, you can define system specific type coercion logic.

Caution that these methods may modify the SqlNode tree, you should know what the effect is when using these methods to customize your type coercion rules.

This class also defines the default implementation of the type widening strategies, see TypeCoercion doc and methods: getTightestCommonType(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType), getWiderTypeFor(java.util.List<org.apache.calcite.rel.type.RelDataType>, boolean), getWiderTypeForTwo(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType, boolean), getWiderTypeForDecimal(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType), commonTypeForBinaryComparison(org.apache.calcite.rel.type.RelDataType, org.apache.calcite.rel.type.RelDataType) for the detail strategies.