public abstract class SqlAggFunction extends SqlFunction implements Context
SqlBasicAggFunctionkind, MDX_PRECEDENCE, NL| Modifier | Constructor and Description |
|---|---|
protected |
SqlAggFunction(String name,
@Nullable SqlIdentifier sqlIdentifier,
SqlKind kind,
SqlReturnTypeInference returnTypeInference,
@Nullable SqlOperandTypeInference operandTypeInference,
@Nullable SqlOperandTypeChecker operandTypeChecker,
SqlFunctionCategory funcType)
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.
|
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.
|
protected |
SqlAggFunction(String name,
SqlKind kind,
SqlReturnTypeInference returnTypeInference,
@Nullable SqlOperandTypeInference operandTypeInference,
@Nullable SqlOperandTypeChecker operandTypeChecker,
SqlFunctionCategory funcType)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowsFilter()
Whether this aggregate function allows a
FILTER (WHERE ...)
clause. |
boolean |
allowsNullTreatment()
Returns whether this aggregate function allows specifying null treatment
(
RESPECT NULLS or IGNORE NULLS). |
Optionality |
getDistinctOptionality()
Returns whether this aggregate function allows the
DISTINCT
keyword. |
List<RelDataType> |
getParameterTypes(RelDataTypeFactory typeFactory)
Deprecated.
|
RelDataType |
getReturnType(RelDataTypeFactory typeFactory)
Deprecated.
|
@Nullable SqlAggFunction |
getRollup()
Gets rollup aggregation function.
|
boolean |
isAggregator()
Returns whether this operator is an aggregate function.
|
boolean |
isPercentile()
Returns whether this aggregate function is a PERCENTILE function.
|
boolean |
isQuantifierAllowed()
Returns whether this function allows a
DISTINCT or
ALL quantifier. |
Optionality |
requiresGroupOrder()
Returns whether this aggregate function must, may, or must not contain a
WITHIN GROUP (ORDER ...) clause. |
boolean |
requiresOrder()
Returns whether this is a window function that requires ordering.
|
boolean |
requiresOver()
Returns whether this is a window function that requires an OVER clause.
|
<T> T |
unwrap(Class<T> clazz)
Finds an instance of an interface implemented by this object,
or returns null if this object does not support that interface.
|
void |
validateCall(SqlCall call,
SqlValidator validator,
SqlValidatorScope scope,
SqlValidatorScope operandScope)
Validates a call to this operator.
|
deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, getSyntax, unparse, validateQuantifieracceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, checkOperandTypes, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperandsclone, finalize, getClass, notify, notifyAll, wait, wait, waitmaybeUnwrap, unwrapOrThrow@Deprecated protected SqlAggFunction(String name, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType)
@Deprecated protected SqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType)
@Deprecated protected SqlAggFunction(String name, @Nullable SqlIdentifier sqlIdentifier, SqlKind kind, SqlReturnTypeInference returnTypeInference, @Nullable SqlOperandTypeInference operandTypeInference, @Nullable SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory funcType, boolean requiresOrder, boolean requiresOver)
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)
A user-defined function will have a value for sqlIdentifier; for
a built-in function it will be null.
public <T> T unwrap(Class<T> clazz)
Wrapperpublic boolean isAggregator()
SqlOperatorPer 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.
isAggregator in class SqlOperatorSqlOperator.requiresOrder()public boolean isQuantifierAllowed()
SqlFunctionDISTINCT or
ALL quantifier. The default is false; some aggregate
functions return true.isQuantifierAllowed in class SqlFunctionpublic void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
SqlOperatorThis 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 of SqlCall never call this method.
validateCall in class SqlFunctioncall - 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 scopesSqlNode.validateExpr(SqlValidator, SqlValidatorScope),
SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)public final boolean requiresOrder()
SqlOperatorPer 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."
requiresOrder in class SqlOperatorSqlOperator.isAggregator()public Optionality requiresGroupOrder()
WITHIN GROUP (ORDER ...) clause.
Cases:
Optionality.MANDATORY,
then AGG(x) WITHIN GROUP (ORDER BY 1) is valid,
and AGG(x) is invalid.
Optionality.OPTIONAL,
then AGG(x) WITHIN GROUP (ORDER BY 1)
and AGG(x) are both valid.
Optionality.IGNORED,
then AGG(x) is valid,
and AGG(x) WITHIN GROUP (ORDER BY 1) is valid but is
treated the same as AGG(x).
Optionality.FORBIDDEN,
then AGG(x) WITHIN GROUP (ORDER BY 1) is invalid,
and AGG(x) is valid.
public final boolean requiresOver()
SqlOperatorFor example, returns true for RANK, DENSE_RANK and
other ranking functions; returns false for SUM, COUNT,
MIN, MAX, AVG (they can be used as non-window
aggregate functions).
If requiresOver returns true, then SqlOperator.isAggregator() must
also return true.
requiresOver in class SqlOperatorSqlOperator.allowsFraming(),
SqlOperator.requiresOrder()public Optionality getDistinctOptionality()
DISTINCT
keyword.
The default implementation returns Optionality.OPTIONAL,
which is appropriate for most aggregate functions, including SUM
and COUNT.
Some aggregate functions, for example MIN, produce the same
result with or without DISTINCT, and therefore return
Optionality.IGNORED to indicate this. For such functions,
Calcite will probably remove DISTINCT while optimizing the query.
@Deprecated public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory)
@Deprecated public RelDataType getReturnType(RelDataTypeFactory typeFactory)
public boolean allowsFilter()
FILTER (WHERE ...)
clause.public boolean allowsNullTreatment()
RESPECT NULLS or IGNORE NULLS).public @Nullable SqlAggFunction getRollup()
public boolean isPercentile()
WITHIN GROUP clause that has precisely
one sort key.
NOTE: This API is experimental and subject to change without notice.
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.