Class SqlFunction
- Direct Known Subclasses:
MockSqlOperatorTable.BadTableFunction
,MockSqlOperatorTable.CompositeFunction
,MockSqlOperatorTable.DedupFunction
,MockSqlOperatorTable.DynamicTypeFunction
,MockSqlOperatorTable.InvalidTableFunction
,MockSqlOperatorTable.MapFunction
,MockSqlOperatorTable.MyFunction
,MockSqlOperatorTable.NotATableFunction
,MockSqlOperatorTable.RampFunction
,MockSqlOperatorTable.RowFunction
,MockSqlOperatorTable.ScoreTableFunction
,MockSqlOperatorTable.SimilarlityTableFunction
,MockSqlOperatorTable.SplitFunction
,MockSqlOperatorTable.StructuredFunction
,MockSqlOperatorTable.TopNTableFunction
,SqlAbstractTimeFunction
,SqlAggFunction
,SqlBaseContextVariable
,SqlBasicFunction
,SqlCastFunction
,SqlCoalesceFunction
,SqlConvertFunction
,SqlCurrentDateFunction
,SqlDatePartFunction
,SqlExtractFunction
,SqlGroupedWindowFunction
,SqlJdbcFunctionCall
,SqlJsonArrayFunction
,SqlJsonDepthFunction
,SqlJsonExistsFunction
,SqlJsonKeysFunction
,SqlJsonLengthFunction
,SqlJsonModifyFunction
,SqlJsonObjectFunction
,SqlJsonPrettyFunction
,SqlJsonQueryFunction
,SqlJsonRemoveFunction
,SqlJsonStorageSizeFunction
,SqlJsonTypeFunction
,SqlJsonValueFunction
,SqlMatchFunction
,SqlMonotonicUnaryFunction
,SqlNullifFunction
,SqlOverlayFunction
,SqlPositionFunction
,SqlRandIntegerFunction
,SqlSubstringFunction
,SqlTimestampAddFunction
,SqlTranslate3Function
,SqlTrimFunction
,SqlTypeConstructorFunction
,SqlUnresolvedFunction
,SqlUserDefinedFunction
,SqlUserDefinedTableMacro
,SqlWindowTableFunction
SqlFunction
is a type of operator which has conventional
function-call syntax.-
Field Summary
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL
-
Constructor Summary
ModifierConstructorDescriptionprotected
SqlFunction
(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, @Nullable List<RelDataType> paramTypes, SqlFunctionCategory category) Deprecated.protected
SqlFunction
(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Internal constructor.SqlFunction
(String name, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates a new SqlFunction for a call to a built-in function.SqlFunction
(SqlIdentifier sqlIdentifier, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, @Nullable List<RelDataType> paramTypes, SqlFunctionCategory funcType) Creates a placeholder SqlFunction for an invocation of a function with a possibly qualified name. -
Method Summary
Modifier and TypeMethodDescriptionderiveType
(SqlValidator validator, SqlValidatorScope scope, SqlCall call) Derives the type of a call to this operator.Return function category.Returns the fully-qualified name of this operator.Deprecated.@Nullable List<RelDataType>
Deprecated.@Nullable SqlIdentifier
Returns the fully-qualified name of function, or null for a built-in function.Returns the syntactic type of this operator, never null.boolean
Returns whether this function allows aDISTINCT
orALL
quantifier.void
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.void
validateCall
(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) Validates a call to this operator.protected void
validateQuantifier
(SqlValidator validator, SqlCall call) Throws a validation error if a DISTINCT or ALL quantifier is present but not allowed.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, getMonotonicity, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands
-
Constructor Details
-
SqlFunction
public SqlFunction(String name, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Creates a new SqlFunction for a call to a built-in function.- Parameters:
name
- Name of built-in functionkind
- kind of operator implemented by functionreturnTypeInference
- strategy to use for return type inferenceoperandTypeInference
- strategy to use for parameter type inferenceoperandTypeChecker
- strategy to use for parameter type checkingcategory
- categorization for function
-
SqlFunction
public SqlFunction(SqlIdentifier sqlIdentifier, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, @Nullable List<RelDataType> paramTypes, SqlFunctionCategory funcType) Creates a placeholder SqlFunction for an invocation of a function with a possibly qualified name. This name must be resolved into either a built-in function or a user-defined function.- Parameters:
sqlIdentifier
- possibly qualified identifier for functionreturnTypeInference
- strategy to use for return type inferenceoperandTypeInference
- strategy to use for parameter type inferenceoperandTypeChecker
- strategy to use for parameter type checkingparamTypes
- array of parameter typesfuncType
- function category
-
SqlFunction
@Deprecated protected SqlFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, @Nullable List<RelDataType> paramTypes, SqlFunctionCategory category) Deprecated. -
SqlFunction
protected SqlFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, @Nullable SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) Internal constructor.
-
-
Method Details
-
getSyntax
Description copied from class:SqlOperator
Returns the syntactic type of this operator, never null.- Specified by:
getSyntax
in classSqlOperator
-
getSqlIdentifier
Returns the fully-qualified name of function, or null for a built-in function. -
getNameAsId
Description copied from class:SqlOperator
Returns the fully-qualified name of this operator.- Overrides:
getNameAsId
in classSqlOperator
-
getParamTypes
Deprecated.UseSqlOperandMetadata.paramTypes(RelDataTypeFactory)
on the result ofSqlOperator.getOperandTypeChecker()
. -
getParamNames
Deprecated.UseSqlOperandMetadata.paramNames()
on the result ofSqlOperator.getOperandTypeChecker()
. -
unparse
Description copied from class:SqlOperator
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.The default implementation of this method delegates to
SqlSyntax.unparse(org.apache.calcite.sql.SqlWriter, org.apache.calcite.sql.SqlOperator, org.apache.calcite.sql.SqlCall, int, int)
.- Overrides:
unparse
in classSqlOperator
-
getFunctionType
Return function category. -
isQuantifierAllowed
@Pure public boolean isQuantifierAllowed()Returns whether this function allows aDISTINCT
orALL
quantifier. The default isfalse
; some aggregate functions returntrue
. -
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 classSqlOperator
- 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:
-
validateQuantifier
Throws a validation error if a DISTINCT or ALL quantifier is present but not allowed. -
deriveType
Description copied from class:SqlOperator
Derives the type of a call to this operator.This method is an intrinsic part of the validation process so, unlike
SqlOperator.inferReturnType(org.apache.calcite.sql.SqlOperatorBinding)
, specific operators would not typically override this method.- Overrides:
deriveType
in classSqlOperator
- Parameters:
validator
- Validatorscope
- Scope of validationcall
- Call to this operator- Returns:
- Type of call
-