Class SqlAggFunction
- Direct Known Subclasses:
MockSqlOperatorTable.MyAggFunc,MockSqlOperatorTable.MyAvgAggFunction,SqlAbstractGroupFunction,SqlAnyValueAggFunction,SqlAvgAggFunction,SqlBasicAggFunction,SqlBitOpAggFunction,SqlCountAggFunction,SqlCovarAggFunction,SqlFirstLastValueAggFunction,SqlHistogramAggFunction,SqlJsonArrayAggAggFunction,SqlJsonObjectAggAggFunction,SqlLeadLagAggFunction,SqlMinMaxAggFunction,SqlNthValueAggFunction,SqlNtileAggFunction,SqlRankFunction,SqlSingleValueAggFunction,SqlSumAggFunction,SqlSumEmptyIsZeroAggFunction,SqlUserDefinedAggFunction
- See Also:
-
Field Summary
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType) Deprecated.protectedSqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType, boolean requiresOrder, boolean requiresOver) Deprecated.protectedSqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType, boolean requiresOrder, boolean requiresOver, Optionality requiresGroupOrder) Creates a built-in or user-defined SqlAggFunction or window function.protectedSqlAggFunction(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this aggregate function allows aFILTER (WHERE ...)clause.booleanReturns whether this aggregate function allows specifying null treatment (RESPECT NULLSorIGNORE NULLS).Returns whether this aggregate function allows theDISTINCTkeyword.getParameterTypes(RelDataTypeFactory typeFactory) Deprecated.getReturnType(RelDataTypeFactory typeFactory) Deprecated.@Nullable SqlAggFunctionGets rollup aggregation function.booleanReturns whether this operator is an aggregate function.booleanReturns whether this aggregate function is a PERCENTILE function.booleanReturns whether this function allows aDISTINCTorALLquantifier.Returns whether this aggregate function must, may, or must not contain aWITHIN GROUP (ORDER ...)clause.final booleanReturns whether this is a window function that requires ordering.final booleanReturns whether this is a window function that requires an OVER clause.<T> @Nullable TFinds an instance of an interface implemented by this object, or returns null if this object does not support that interface.voidvalidateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope) Validates a call to this operator.Methods inherited from class org.apache.calcite.sql.SqlFunction
deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, getSyntax, 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, getMonotonicity, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getSqlCallFactory, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSafeOperator, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperandsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.schema.Wrapper
maybeUnwrap, unwrapOrThrow
-
Constructor Details
-
SqlAggFunction
@Deprecated protected SqlAggFunction(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType) Deprecated.Creates a built-in SqlAggFunction. -
SqlAggFunction
@Deprecated protected SqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType) Deprecated.Creates a user-defined SqlAggFunction. -
SqlAggFunction
@Deprecated protected SqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType, boolean requiresOrder, boolean requiresOver) Deprecated. -
SqlAggFunction
protected SqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType, boolean requiresOrder, boolean requiresOver, Optionality requiresGroupOrder) Creates a built-in or user-defined SqlAggFunction or window function.A user-defined function will have a value for
sqlIdentifier; for a built-in function it will be null.
-
-
Method Details
-
unwrap
Description copied from interface:WrapperFinds an instance of an interface implemented by this object, or returns null if this object does not support that interface. -
isAggregator
public boolean isAggregator()Description copied from class:SqlOperatorReturns whether this operator is an aggregate function. By default, subclass type is used (an instance of SqlAggFunction is assumed to be an aggregator; anything else is not).Per SQL:2011, there are aggregate functions and window functions. Every aggregate function (e.g. SUM) is also a window function. There are window functions that are not aggregate functions, e.g. RANK, NTILE, LEAD, FIRST_VALUE.
Collectively, aggregate and window functions are called analytic functions. Despite its name, this method returns true for every analytic function.
- Overrides:
isAggregatorin classSqlOperator- Returns:
- whether this operator is an analytic function (aggregate function or window function)
- See Also:
-
isQuantifierAllowed
public boolean isQuantifierAllowed()Description copied from class:SqlFunctionReturns whether this function allows aDISTINCTorALLquantifier. The default isfalse; some aggregate functions returntrue.- Overrides:
isQuantifierAllowedin classSqlFunction
-
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 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:
-
requiresOrder
public final boolean requiresOrder()Description copied from class:SqlOperatorReturns whether this is a window function that requires ordering.Per SQL:2011, 2, 6.10: "If <ntile function>, <lead or lag function>, RANK or DENSE_RANK is specified, then the window ordering clause shall be present."
- Overrides:
requiresOrderin classSqlOperator- See Also:
-
requiresGroupOrder
Returns whether this aggregate function must, may, or must not contain aWITHIN GROUP (ORDER ...)clause.Cases:
- If
Optionality.MANDATORY, thenAGG(x) WITHIN GROUP (ORDER BY 1)is valid, andAGG(x)is invalid. - If
Optionality.OPTIONAL, thenAGG(x) WITHIN GROUP (ORDER BY 1)andAGG(x)are both valid. - If
Optionality.IGNORED, thenAGG(x)is valid, andAGG(x) WITHIN GROUP (ORDER BY 1)is valid but is treated the same asAGG(x). - If
Optionality.FORBIDDEN, thenAGG(x) WITHIN GROUP (ORDER BY 1)is invalid, andAGG(x)is valid.
- If
-
requiresOver
public final boolean requiresOver()Description copied from class:SqlOperatorReturns whether this is a window function that requires an OVER clause.For example, returns true for
RANK,DENSE_RANKand other ranking functions; returns false forSUM,COUNT,MIN,MAX,AVG(they can be used as non-window aggregate functions).If
requiresOverreturns true, thenSqlOperator.isAggregator()must also return true.- Overrides:
requiresOverin classSqlOperator- See Also:
-
getDistinctOptionality
Returns whether this aggregate function allows theDISTINCTkeyword.The default implementation returns
Optionality.OPTIONAL, which is appropriate for most aggregate functions, includingSUMandCOUNT.Some aggregate functions, for example
MIN, produce the same result with or withoutDISTINCT, and therefore returnOptionality.IGNOREDto indicate this. For such functions, Calcite will probably removeDISTINCTwhile optimizing the query. -
getParameterTypes
Deprecated. -
getReturnType
Deprecated. -
allowsFilter
public boolean allowsFilter()Whether this aggregate function allows aFILTER (WHERE ...)clause. -
allowsNullTreatment
public boolean allowsNullTreatment()Returns whether this aggregate function allows specifying null treatment (RESPECT NULLSorIGNORE NULLS). -
getRollup
Gets rollup aggregation function. -
isPercentile
public boolean isPercentile()Returns whether this aggregate function is a PERCENTILE function. Such functions require aWITHIN GROUPclause that has precisely one sort key.NOTE: This API is experimental and subject to change without notice.
-