org.eigenbase.sql.validate
Class SelectScope

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

public class SelectScope
extends ListScope

The name-resolution scope of a SELECT clause. The objects visible are those in the FROM clause, and objects inherited from the parent scope.

This object is both a SqlValidatorScope and a SqlValidatorNamespace. In the query

SELECT name FROM (
     SELECT *
     FROM emp
     WHERE gender = 'F')

we need to use the SelectScope as a SqlValidatorNamespace when resolving 'name', and as a SqlValidatorScope when resolving 'gender'.

Scopes

In the query

 SELECT expr1
 FROM t1,
     t2,
     (SELECT expr2 FROM t3) AS q3
 WHERE c1 IN (SELECT expr3 FROM t4)
 ORDER BY expr4

The scopes available at various points of the query are as follows:

Namespaces

In the above query, there are 4 namespaces:

Since:
Mar 25, 2003
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/validate/SelectScope.java#17 $
Author:
jhyde
See Also:
SelectNamespace

Field Summary
private  List<SqlNode> expandedSelectList
           
private  SqlNodeList orderList
          List of column names which sort this scope.
private  SqlSelect select
           
protected  List<String> windowNames
           
private  SqlValidatorScope windowParent
          Scope to use to resolve windows
 
Fields inherited from class org.eigenbase.sql.validate.ListScope
children, childrenNames
 
Fields inherited from class org.eigenbase.sql.validate.DelegatingScope
parent, validator
 
Constructor Summary
SelectScope(SqlValidatorScope parent, SqlValidatorScope winParent, SqlSelect select)
          Creates a scope corresponding to a SELECT clause.
 
Method Summary
 void addWindowName(String winName)
           
 boolean existingWindowName(String winName)
           
 List<SqlNode> getExpandedSelectList()
           
 SqlMonotonicity getMonotonicity(SqlNode expr)
          Returns whether an expression is monotonic in this scope.
 SqlSelect getNode()
          Returns the root node of this scope.
 SqlNodeList getOrderList()
          Returns the expressions by which the rows in this scope are sorted.
 SqlValidatorTable getTable()
           
 SqlWindow lookupWindow(String name)
          Finds a window with a given name.
 void setExpandedSelectList(List<SqlNode> selectList)
           
 
Methods inherited from class org.eigenbase.sql.validate.ListScope
addChild, findAliases, findAllColumnNames, findQualifyingTableName, getChild, getChildren, resolve, resolveColumn
 
Methods inherited from class org.eigenbase.sql.validate.DelegatingScope
addColumnNames, fullyQualify, getOperandScope, getParent, getValidator, validateExpr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

select

private final SqlSelect select

windowNames

protected final List<String> windowNames

expandedSelectList

private List<SqlNode> expandedSelectList

orderList

private SqlNodeList orderList
List of column names which sort this scope. Empty if this scope is not sorted. Null if has not been computed yet.


windowParent

private final SqlValidatorScope windowParent
Scope to use to resolve windows

Constructor Detail

SelectScope

SelectScope(SqlValidatorScope parent,
            SqlValidatorScope winParent,
            SqlSelect select)
Creates a scope corresponding to a SELECT clause.

Parameters:
parent - Parent scope, must not be null
winParent - Scope for window parent, may be null
select - Select clause
Method Detail

getTable

public SqlValidatorTable getTable()

getNode

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


lookupWindow

public SqlWindow lookupWindow(String name)
Description copied from interface: SqlValidatorScope
Finds a window with a given name. Returns null if not found.

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

getMonotonicity

public SqlMonotonicity getMonotonicity(SqlNode expr)
Description copied from interface: SqlValidatorScope
Returns whether an expression is monotonic in this scope. For example, if the scope has previously been sorted by columns X, Y, then X is monotonic in this scope, but Y is not.

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

getOrderList

public SqlNodeList getOrderList()
Description copied from interface: SqlValidatorScope
Returns the expressions by which the rows in this scope are sorted. If the rows are unsorted, returns null.

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

addWindowName

public void addWindowName(String winName)

existingWindowName

public boolean existingWindowName(String winName)

getExpandedSelectList

public List<SqlNode> getExpandedSelectList()

setExpandedSelectList

public void setExpandedSelectList(List<SqlNode> selectList)