Package org.apache.calcite.sql
Class SqlBasicFunction
java.lang.Object
org.apache.calcite.sql.SqlOperator
org.apache.calcite.sql.SqlFunction
org.apache.calcite.sql.SqlBasicFunction
Concrete implementation of
SqlFunction
.
The class is final, and instances are immutable.
Instances are created only by create(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, 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.rewriteCall
(SqlValidator validator, SqlCall call) Rewrites a call to this operator.withDeterministic
(boolean deterministic) Returns a copy of this function with a given determinism.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.withOperandTypeInference
(SqlOperandTypeInference operandTypeInference) Returns a copy of this function with a given strategy for inferring the types of its operands.withSyntax
(SqlSyntax syntax) Returns a copy of this function with a given syntax.Methods inherited from class org.apache.calcite.sql.SqlFunction
deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, isQuantifierAllowed, unparse, validateCall, 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, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands
-
Method Details
-
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
-
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. -
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.
-