Class SqlCastFunction


  • public class SqlCastFunction
    extends org.apache.calcite.sql.SqlFunction
    SqlCastFunction. Note that the std functions are really singleton objects, because they always get fetched via the StdOperatorTable. So you can't store any local info in the class and hence the return type data is maintained in operand[1] through the validation phase.

    Can be used for both SqlCall and RexCall. Note that the SqlCall has two operands (expression and type), while the RexCall has one operand (expression) and the type is obtained from RexNode.getType().

    The class was copied over because of CALCITE-5017, in order to workaround the method SqlTypeUtil.canCastFrom(RelDataType, RelDataType, boolean). Line 141 in checkOperandTypes(SqlCallBinding, boolean) and new method canCastFrom(RelDataType, RelDataType).

    See Also:
    SqlCastOperator
    • Field Summary

      • Fields inherited from class org.apache.calcite.sql.SqlOperator

        kind, MDX_PRECEDENCE, NL
    • Constructor Summary

      Constructors 
      Constructor Description
      SqlCastFunction()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkOperandTypes​(org.apache.calcite.sql.SqlCallBinding callBinding, boolean throwOnFailure)
      Makes sure that the number and types of arguments are allowable.
      org.apache.calcite.sql.validate.SqlMonotonicity getMonotonicity​(org.apache.calcite.sql.SqlOperatorBinding call)  
      org.apache.calcite.sql.SqlOperandCountRange getOperandCountRange()  
      String getSignatureTemplate​(int operandsCount)  
      org.apache.calcite.sql.SqlSyntax getSyntax()  
      org.apache.calcite.rel.type.RelDataType inferReturnType​(org.apache.calcite.sql.SqlOperatorBinding opBinding)  
      void unparse​(org.apache.calcite.sql.SqlWriter writer, org.apache.calcite.sql.SqlCall call, int leftPrec, int rightPrec)  
      • Methods inherited from class org.apache.calcite.sql.SqlFunction

        deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, isQuantifierAllowed, validateCall, validateQuantifier
      • Methods inherited from class org.apache.calcite.sql.SqlOperator

        acceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, deriveOperandType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getName, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getStrongPolicyInference, hashCode, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands
    • Constructor Detail

      • SqlCastFunction

        public SqlCastFunction()
    • Method Detail

      • inferReturnType

        public org.apache.calcite.rel.type.RelDataType inferReturnType​(org.apache.calcite.sql.SqlOperatorBinding opBinding)
        Overrides:
        inferReturnType in class org.apache.calcite.sql.SqlOperator
      • getSignatureTemplate

        public String getSignatureTemplate​(int operandsCount)
        Overrides:
        getSignatureTemplate in class org.apache.calcite.sql.SqlOperator
      • getOperandCountRange

        public org.apache.calcite.sql.SqlOperandCountRange getOperandCountRange()
        Overrides:
        getOperandCountRange in class org.apache.calcite.sql.SqlOperator
      • checkOperandTypes

        public boolean checkOperandTypes​(org.apache.calcite.sql.SqlCallBinding callBinding,
                                         boolean throwOnFailure)
        Makes sure that the number and types of arguments are allowable. Operators (such as "ROW" and "AS") which do not check their arguments can override this method.
        Overrides:
        checkOperandTypes in class org.apache.calcite.sql.SqlOperator
      • getSyntax

        public org.apache.calcite.sql.SqlSyntax getSyntax()
        Overrides:
        getSyntax in class org.apache.calcite.sql.SqlFunction
      • unparse

        public void unparse​(org.apache.calcite.sql.SqlWriter writer,
                            org.apache.calcite.sql.SqlCall call,
                            int leftPrec,
                            int rightPrec)
        Overrides:
        unparse in class org.apache.calcite.sql.SqlFunction
      • getMonotonicity

        public org.apache.calcite.sql.validate.SqlMonotonicity getMonotonicity​(org.apache.calcite.sql.SqlOperatorBinding call)
        Overrides:
        getMonotonicity in class org.apache.calcite.sql.SqlOperator