Package org.apache.calcite.sql.validate
Class AggregatingSelectScope
java.lang.Object
org.apache.calcite.sql.validate.DelegatingScope
org.apache.calcite.sql.validate.AggregatingSelectScope
- All Implemented Interfaces:
AggregatingScope,SqlValidatorScope
Scope for resolving identifiers within a SELECT statement that has a
GROUP BY clause.
The same set of identifiers are in scope, but it won't allow access to identifiers or expressions which are not group-expressions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInformation about an aggregating scope that can only be determined after validation has occurred.Nested classes/interfaces inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
SqlValidatorScope.EmptyPath, SqlValidatorScope.Path, SqlValidatorScope.Resolve, SqlValidatorScope.ResolvedImpl, SqlValidatorScope.Step -
Field Summary
Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, resolved, validator -
Method Summary
Modifier and TypeMethodDescriptionprotected voidanalyze(org.apache.calcite.sql.validate.SqlValidatorUtil.GroupAnalyzer analyzer) Analyzes expressions in this scope and populates aGroupAnalyzer.booleancheckAggregateExpr(SqlNode expr, boolean deep) Checks whether an expression is constant within the GROUP BY clause.getNode()Returns the root node of this scope.getOperandScope(SqlCall call) Returns the scope within which operands to a call are to be validated.nullifyType(SqlNode node, RelDataType type) Converts the type of an expression to nullable, if the context warrants it.voidvalidateExpr(SqlNode expr) Performs any scope-specific validation of an expression.Methods inherited from class org.apache.calcite.sql.validate.DelegatingScope
addChild, addColumnNames, findAliases, findAllColumnNames, findQualifyingTableName, findQualifyingTableNames, fullyQualify, getMonotonicity, getOrderList, getParent, getTableNamespace, getValidator, lookupWindow, qualifyUsingAlias, resolve, resolveColumn, resolveTableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
addChild, findAliases, findAllColumnNames, findQualifyingTableName, findQualifyingTableNames, fullyQualify, getMonotonicity, getOrderList, getTableNamespace, getValidator, isMeasureRef, isWithin, lookupWindow, resolve, resolveColumn, resolveTable
-
Method Details
-
analyze
protected void analyze(org.apache.calcite.sql.validate.SqlValidatorUtil.GroupAnalyzer analyzer) Description copied from class:DelegatingScopeAnalyzes expressions in this scope and populates aGroupAnalyzer.- Overrides:
analyzein classDelegatingScope
-
getNode
Description copied from interface:SqlValidatorScopeReturns the root node of this scope. Never null.- Specified by:
getNodein interfaceSqlValidatorScope
-
nullifyType
Description copied from interface:SqlValidatorScopeConverts the type of an expression to nullable, if the context warrants it.- Specified by:
nullifyTypein interfaceSqlValidatorScope- Overrides:
nullifyTypein classDelegatingScope
-
getOperandScope
Description copied from interface:SqlValidatorScopeReturns the scope within which operands to a call are to be validated. Usually it is this scope, but when the call is to an aggregate function and this is an aggregating scope, it will be a a different scope.- Specified by:
getOperandScopein interfaceSqlValidatorScope- Overrides:
getOperandScopein classDelegatingScope- Parameters:
call- Call- Returns:
- Scope within which to validate arguments to call.
-
checkAggregateExpr
Description copied from interface:AggregatingScopeChecks whether an expression is constant within the GROUP BY clause. If the expression completely matches an expression in the GROUP BY clause, returns true. If the expression is constant within the group, but does not exactly match, returns false. If the expression is not constant, throws an exception. Examples:- If we are 'f(b, c)' in 'SELECT a + f(b, c) FROM t GROUP BY a', then the whole expression matches a group column. Return true.
- Just an ordinary expression in a GROUP BY query, such as 'f(SUM(a), 1, b)' in 'SELECT f(SUM(a), 1, b) FROM t GROUP BY b'. Returns false.
- Illegal expression, such as 'f(5, a, b)' in 'SELECT f(a, b) FROM t GROUP BY a'. Throws when it enounters the 'b' operand, because it is not in the group clause.
- Specified by:
checkAggregateExprin interfaceAggregatingScope
-
validateExpr
Description copied from interface:SqlValidatorScopePerforms any scope-specific validation of an expression. For example, an aggregating scope requires that expressions are valid aggregations. The expression has already been validated.- Specified by:
validateExprin interfaceSqlValidatorScope- Overrides:
validateExprin classDelegatingScope
-