org.eigenbase.sql.validate
Class OrderByScope

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

public class OrderByScope
extends DelegatingScope

Represents the name-resolution context for expressions in an ORDER BY clause.

In some dialects of SQL, the ORDER BY clause can reference column aliases in the SELECT clause. For example, the query

SELECT empno AS x
FROM emp
ORDER BY x
is valid.

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

Field Summary
private  SqlNodeList orderList
           
private  SqlSelect select
           
 
Fields inherited from class org.eigenbase.sql.validate.DelegatingScope
parent, validator
 
Constructor Summary
OrderByScope(SqlValidatorScope parent, SqlNodeList orderList, SqlSelect select)
           
 
Method Summary
 void findAllColumnNames(List<SqlMoniker> result)
          Collects the SqlMonikers of all possible columns in this scope.
 SqlIdentifier fullyQualify(SqlIdentifier identifier)
          Converts an identifier into a fully-qualified identifier.
 SqlNode getNode()
          Returns the root node of this scope.
 RelDataType resolveColumn(String name, SqlNode ctx)
          Resolves a single identifier to a column, and returns the datatype of that column.
 void validateExpr(SqlNode expr)
          Performs any scope-specific validation of an expression.
 
Methods inherited from class org.eigenbase.sql.validate.DelegatingScope
addChild, addColumnNames, findAliases, findQualifyingTableName, getMonotonicity, getOperandScope, getOrderList, getParent, getValidator, lookupWindow, resolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orderList

private final SqlNodeList orderList

select

private final SqlSelect select
Constructor Detail

OrderByScope

OrderByScope(SqlValidatorScope parent,
             SqlNodeList orderList,
             SqlSelect select)
Method Detail

getNode

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


findAllColumnNames

public void findAllColumnNames(List<SqlMoniker> result)
Description copied from interface: SqlValidatorScope
Collects the SqlMonikers of all possible columns in this scope.

Specified by:
findAllColumnNames in interface SqlValidatorScope
Overrides:
findAllColumnNames in class DelegatingScope
Parameters:
result - an array list of strings to add the result to

fullyQualify

public SqlIdentifier fullyQualify(SqlIdentifier identifier)
Description copied from class: DelegatingScope
Converts an identifier into a fully-qualified identifier. For example, the "empno" in "select empno from emp natural join dept" becomes "emp.empno".

If the identifier cannot be resolved, throws. Never returns null.

Specified by:
fullyQualify in interface SqlValidatorScope
Overrides:
fullyQualify in class DelegatingScope

resolveColumn

public RelDataType resolveColumn(String name,
                                 SqlNode ctx)
Description copied from interface: SqlValidatorScope
Resolves a single identifier to a column, and returns the datatype of that column.

If it cannot find the column, returns null. If the column is ambiguous, throws an error with context ctx.

Specified by:
resolveColumn in interface SqlValidatorScope
Overrides:
resolveColumn in class DelegatingScope
Parameters:
name - Name of column
ctx - Context for exception
Returns:
Type of column, if found and unambiguous; null if not found

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