Class SqlBasicFunction
SqlFunction
.
The class is final, and instances are immutable.
Instances are created only by create(java.lang.String, org.apache.calcite.sql.SqlKind, org.apache.calcite.sql.type.SqlReturnTypeInference, org.apache.calcite.sql.type.SqlOperandTypeChecker)
and are
"modified" by "wither" methods such as withName(java.lang.String)
to create a new
instance with one property changed. Since the class is final, you can modify
behavior only by providing strategy objects, not by overriding methods in a
subclass.
-
Field Summary
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL
-
Method Summary
Modifier and TypeMethodDescriptionstatic SqlBasicFunction
create
(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
.static SqlBasicFunction
create
(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
with kindSqlKind.OTHER_FUNCTION
and categorySqlFunctionCategory.NUMERIC
.static SqlBasicFunction
create
(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates aSqlBasicFunction
with kindSqlKind.OTHER_FUNCTION
.static SqlBasicFunction
create
(SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
whose name is the same as its kind and whose categorySqlFunctionCategory.SYSTEM
.Returns whether a call to this operator is monotonic.Returns the return type inference strategy for this operator, or null if return type inference is implemented by a subclass override.Returns the syntactic type of this operator, never null.boolean
Returns whether a call to this operator is guaranteed to always return the same result given the same operands; true is assumed by default.boolean
Returns whether it is unsafe to cache query plans referencing this operator; false is assumed by default.rewriteCall
(SqlValidator validator, SqlCall call) Rewrites a call to this operator.void
validateCall
(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) Validates a call to this operator.withDeterministic
(boolean deterministic) Returns a copy of this function with a given determinism.withDynamic
(boolean dynamic) withFunctionType
(SqlFunctionCategory category) Returns a copy of this function with a given category.Returns a copy of this function with a given kind.withMonotonicityInference
(Function<SqlOperatorBinding, SqlMonotonicity> monotonicityInference) Returns a copy of this function with a given strategy for inferring whether a call is monotonic.Returns a copy of this function with a given name.withOperandHandler
(SqlOperandHandler operandHandler) Returns a copy of this function with a given strategy for handling operands.withOperandTypeChecker
(SqlOperandTypeChecker operandTypeChecker) withOperandTypeInference
(SqlOperandTypeInference operandTypeInference) Returns a copy of this function with a given strategy for inferring the types of its operands.withReturnTypeInference
(SqlReturnTypeInference returnTypeInference) Returns a copy of this function with a given strategy for inferring returned type.withSyntax
(SqlSyntax syntax) Returns a copy of this function with a given syntax.withValidation
(int callValidator) Methods inherited from class org.apache.calcite.sql.SqlFunction
deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, isQuantifierAllowed, unparse, validateQuantifier
Methods inherited from class org.apache.calcite.sql.SqlOperator
acceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, checkOperandTypes, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, deriveOperandType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getName, getOperandCountRange, getOperandTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isAggregator, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands
-
Method Details
-
create
public static SqlBasicFunction create(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
.- Parameters:
name
- function namekind
- function kindreturnTypeInference
- Strategy to use for return type inferenceoperandTypeChecker
- Strategy to use for parameter type checking- Returns:
- a
SqlBasicFunction
-
create
public static SqlBasicFunction create(SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
whose name is the same as its kind and whose categorySqlFunctionCategory.SYSTEM
. -
create
public static SqlBasicFunction create(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction
with kindSqlKind.OTHER_FUNCTION
and categorySqlFunctionCategory.NUMERIC
. -
create
public static SqlBasicFunction create(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates aSqlBasicFunction
with kindSqlKind.OTHER_FUNCTION
. -
getReturnTypeInference
Description copied from class:SqlOperator
Returns the return type inference strategy for this operator, or null if return type inference is implemented by a subclass override.- Overrides:
getReturnTypeInference
in classSqlOperator
-
getOperandTypeChecker
- Overrides:
getOperandTypeChecker
in classSqlOperator
-
getSyntax
Description copied from class:SqlOperator
Returns the syntactic type of this operator, never null.- Overrides:
getSyntax
in classSqlFunction
-
isDeterministic
public boolean isDeterministic()Description copied from class:SqlOperator
Returns whether a call to this operator is guaranteed to always return the same result given the same operands; true is assumed by default.- Overrides:
isDeterministic
in classSqlOperator
-
getMonotonicity
Description copied from class:SqlOperator
Returns whether a call to this operator is monotonic.Default implementation returns
SqlMonotonicity.NOT_MONOTONIC
.- Overrides:
getMonotonicity
in classSqlOperator
- Parameters:
call
- Call to this operator with particular arguments and information about the monotonicity of the arguments
-
rewriteCall
Description copied from class:SqlOperator
Rewrites a call to this operator. Some operators are implemented as trivial rewrites (e.g. NULLIF becomes CASE). However, we don't do this at createCall time because we want to preserve the original SQL syntax as much as possible; instead, we do this before the call is validated (so the trivial operator doesn't need its own implementation of type derivation methods). The default implementation is to just return the original call without any rewrite.- Overrides:
rewriteCall
in classSqlOperator
- Parameters:
validator
- Validatorcall
- Call to be rewritten- Returns:
- rewritten call
-
validateCall
public void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) Description copied from class:SqlOperator
Validates a call to this operator.This method should not perform type-derivation or perform validation related related to types. That is done later, by
SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)
. This method should focus on structural validation.A typical implementation of this method first validates the operands, then performs some operator-specific logic. The default implementation just validates the operands.
This method is the default implementation of
SqlCall.validate(org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope)
; but note that some sub-classes ofSqlCall
never call this method.- Overrides:
validateCall
in classSqlFunction
- Parameters:
call
- the call to this operatorvalidator
- the active validatorscope
- validator scopeoperandScope
- validator scope in which to validate operands to this call; usually equal to scope, but not always because some operators introduce new scopes- See Also:
-
isDynamicFunction
public boolean isDynamicFunction()Description copied from class:SqlOperator
Returns whether it is unsafe to cache query plans referencing this operator; false is assumed by default.- Overrides:
isDynamicFunction
in classSqlOperator
-
withName
Returns a copy of this function with a given name. -
withKind
Returns a copy of this function with a given kind. -
withFunctionType
Returns a copy of this function with a given category. -
withSyntax
Returns a copy of this function with a given syntax. -
withReturnTypeInference
Returns a copy of this function with a given strategy for inferring returned type. -
withOperandTypeInference
Returns a copy of this function with a given strategy for inferring the types of its operands. -
withOperandHandler
Returns a copy of this function with a given strategy for handling operands. -
withDeterministic
Returns a copy of this function with a given determinism. -
withMonotonicityInference
public SqlBasicFunction withMonotonicityInference(Function<SqlOperatorBinding, SqlMonotonicity> monotonicityInference) Returns a copy of this function with a given strategy for inferring whether a call is monotonic. -
withValidation
-
withDynamic
-
withOperandTypeChecker
-