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 SqlBasicFunctioncreate(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunction.static SqlBasicFunctioncreate(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunctionwith kindSqlKind.OTHER_FUNCTIONand categorySqlFunctionCategory.NUMERIC.static SqlBasicFunctioncreate(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates aSqlBasicFunctionwith kindSqlKind.OTHER_FUNCTION.static SqlBasicFunctioncreate(SqlKind kind, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunctionwhose 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.booleanReturns whether a call to this operator is guaranteed to always return the same result given the same operands; true is assumed by default.booleanReturns whether it is unsafe to cache query plans referencing this operator; false is assumed by default.@Nullable SqlOperatorreverse()Returns the operator that has the same effect as this operator if its arguments are reversed.rewriteCall(SqlValidator validator, SqlCall call) Rewrites a call to this operator.voidvalidateCall(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, validateQuantifierMethods 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, getSqlCallFactory, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isAggregator, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, 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 aSqlBasicFunctionwhose name is the same as its kind and whose categorySqlFunctionCategory.SYSTEM. -
create
public static SqlBasicFunction create(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker) Creates aSqlBasicFunctionwith kindSqlKind.OTHER_FUNCTIONand categorySqlFunctionCategory.NUMERIC. -
create
public static SqlBasicFunction create(String name, SqlReturnTypeInference returnTypeInference, SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates aSqlBasicFunctionwith kindSqlKind.OTHER_FUNCTION. -
getReturnTypeInference
Description copied from class:SqlOperatorReturns the return type inference strategy for this operator, or null if return type inference is implemented by a subclass override.- Overrides:
getReturnTypeInferencein classSqlOperator
-
getOperandTypeChecker
- Overrides:
getOperandTypeCheckerin classSqlOperator
-
getSyntax
Description copied from class:SqlOperatorReturns the syntactic type of this operator, never null.- Overrides:
getSyntaxin classSqlFunction
-
isDeterministic
public boolean isDeterministic()Description copied from class:SqlOperatorReturns whether a call to this operator is guaranteed to always return the same result given the same operands; true is assumed by default.- Overrides:
isDeterministicin classSqlOperator
-
reverse
Description copied from class:SqlOperatorReturns the operator that has the same effect as this operator if its arguments are reversed.For example,
SqlStdOperatorTable.GREATER_THAN.reverse()returnsSqlStdOperatorTable.LESS_THAN, and vice versa, becausea > bis equivalent tob < a.SqlStdOperatorTable.EQUALS.reverse()returns itself.By default, returns
null, which means there is no inverse operator.- Overrides:
reversein classSqlOperator- See Also:
-
getMonotonicity
Description copied from class:SqlOperatorReturns whether a call to this operator is monotonic.Default implementation returns
SqlMonotonicity.NOT_MONOTONIC.- Overrides:
getMonotonicityin classSqlOperator- Parameters:
call- Call to this operator with particular arguments and information about the monotonicity of the arguments
-
rewriteCall
Description copied from class:SqlOperatorRewrites 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:
rewriteCallin 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:SqlOperatorValidates 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 ofSqlCallnever call this method.- Overrides:
validateCallin 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:SqlOperatorReturns whether it is unsafe to cache query plans referencing this operator; false is assumed by default.- Overrides:
isDynamicFunctionin 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
-