org.eigenbase.sql.validate
Class AggregatingSelectScope

java.lang.Object
  extended by org.eigenbase.sql.validate.DelegatingScope
      extended by org.eigenbase.sql.validate.AggregatingSelectScope
All Implemented Interfaces:
AggregatingScope, SqlValidatorScope

public class AggregatingSelectScope
extends DelegatingScope
implements AggregatingScope

Scope for resolving identifers within a SELECT statement which 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.

Since:
Mar 25, 2003
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/validate/AggregatingSelectScope.java#11 $
Author:
jhyde

Field Summary
private  boolean distinct
           
private  List<SqlNode> groupExprList
           
private  SqlSelect select
           
 
Fields inherited from class org.eigenbase.sql.validate.DelegatingScope
parent, validator
 
Constructor Summary
AggregatingSelectScope(SqlValidatorScope selectScope, SqlSelect select, boolean distinct)
           
 
Method Summary
 boolean checkAggregateExpr(SqlNode expr, boolean deep)
          Checks whether an expression is constant within the GROUP BY clause.
private  List<SqlNode> getGroupExprs()
          Returns the expressions that are in the GROUP BY clause (or the SELECT DISTINCT clause, if distinct) and that can therefore be referenced without being wrapped in aggregate functions.
 SqlNode getNode()
          Returns the root node of this scope.
 SqlValidatorScope getOperandScope(SqlCall call)
          Returns the scope within which operands to a call are to be validated.
 void validateExpr(SqlNode expr)
          Performs any scope-specific validation of an expression.
 
Methods inherited from class org.eigenbase.sql.validate.DelegatingScope
addChild, addColumnNames, findAliases, findAllColumnNames, findQualifyingTableName, fullyQualify, getMonotonicity, getOrderList, getParent, getValidator, lookupWindow, resolve, resolveColumn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eigenbase.sql.validate.SqlValidatorScope
addChild, findAliases, findAllColumnNames, findQualifyingTableName, fullyQualify, getMonotonicity, getOrderList, getValidator, lookupWindow, resolve, resolveColumn
 

Field Detail

select

private final SqlSelect select

distinct

private final boolean distinct

groupExprList

private final List<SqlNode> groupExprList
Constructor Detail

AggregatingSelectScope

AggregatingSelectScope(SqlValidatorScope selectScope,
                       SqlSelect select,
                       boolean distinct)
Method Detail

getGroupExprs

private List<SqlNode> getGroupExprs()
Returns the expressions that are in the GROUP BY clause (or the SELECT DISTINCT clause, if distinct) and that can therefore be referenced without being wrapped in aggregate functions.

The expressions are fully-qualified, and any "*" in select clauses are expanded.

Returns:
list of grouping expressions

getNode

public SqlNode getNode()
Description copied from interface: SqlValidatorScope
Returns the root node of this scope.

Specified by:
getNode in interface SqlValidatorScope

getOperandScope

public SqlValidatorScope getOperandScope(SqlCall call)
Description copied from interface: SqlValidatorScope
Returns 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:
getOperandScope in interface SqlValidatorScope
Overrides:
getOperandScope in class DelegatingScope
Parameters:
call - Call
Returns:
Scope within which to validate arguments to call.

checkAggregateExpr

public boolean checkAggregateExpr(SqlNode expr,
                                  boolean deep)
Description copied from interface: AggregatingScope
Checks 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:

Specified by:
checkAggregateExpr in interface AggregatingScope

validateExpr

public void validateExpr(SqlNode expr)
Description copied from interface: SqlValidatorScope
Performs 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:
validateExpr in interface SqlValidatorScope
Overrides:
validateExpr in class DelegatingScope