org.eigenbase.sql.validate
Class ListScope

java.lang.Object
  extended by org.eigenbase.sql.validate.DelegatingScope
      extended by org.eigenbase.sql.validate.ListScope
All Implemented Interfaces:
SqlValidatorScope
Direct Known Subclasses:
CollectScope, JoinScope, OverScope, SelectScope

public abstract class ListScope
extends DelegatingScope

Abstract base for a scope which is defined by a list of child namespaces and which inherits from a parent scope.

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

Field Summary
protected  List<SqlValidatorNamespace> children
          List of child SqlValidatorNamespace objects.
protected  List<String> childrenNames
          Aliases of the SqlValidatorNamespace objects.
 
Fields inherited from class org.eigenbase.sql.validate.DelegatingScope
parent, validator
 
Constructor Summary
ListScope(SqlValidatorScope parent)
           
 
Method Summary
 void addChild(SqlValidatorNamespace ns, String alias)
          Registers a relation in this scope.
 void findAliases(List<SqlMoniker> result)
          Collects the SqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.
 void findAllColumnNames(List<SqlMoniker> result)
          Collects the SqlMonikers of all possible columns in this scope.
 String findQualifyingTableName(String columnName, SqlNode ctx)
          Finds the table alias which is implicitly qualifying an unqualified column name.
protected  SqlValidatorNamespace getChild(String alias)
           
 List<SqlValidatorNamespace> getChildren()
          Returns an immutable list of child namespaces.
 SqlValidatorNamespace resolve(String name, SqlValidatorScope[] ancestorOut, int[] offsetOut)
          Looks up a node with a given name.
 RelDataType resolveColumn(String columnName, SqlNode ctx)
          Resolves a single identifier to a column, and returns the datatype of that column.
 
Methods inherited from class org.eigenbase.sql.validate.DelegatingScope
addColumnNames, fullyQualify, getMonotonicity, getOperandScope, getOrderList, getParent, getValidator, lookupWindow, validateExpr
 
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
getNode
 

Field Detail

children

protected final List<SqlValidatorNamespace> children
List of child SqlValidatorNamespace objects.


childrenNames

protected final List<String> childrenNames
Aliases of the SqlValidatorNamespace objects.

Constructor Detail

ListScope

public ListScope(SqlValidatorScope parent)
Method Detail

addChild

public void addChild(SqlValidatorNamespace ns,
                     String alias)
Description copied from interface: SqlValidatorScope
Registers a relation in this scope.

Specified by:
addChild in interface SqlValidatorScope
Overrides:
addChild in class DelegatingScope
Parameters:
ns - Namespace representing the result-columns of the relation
alias - Alias with which to reference the relation, must not be null

getChildren

public List<SqlValidatorNamespace> getChildren()
Returns an immutable list of child namespaces.

Returns:
list of child namespaces

getChild

protected SqlValidatorNamespace getChild(String alias)

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

findAliases

public void findAliases(List<SqlMoniker> result)
Description copied from interface: SqlValidatorScope
Collects the SqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.

Specified by:
findAliases in interface SqlValidatorScope
Overrides:
findAliases in class DelegatingScope
Parameters:
result - a list of monikers to add the result to

findQualifyingTableName

public String findQualifyingTableName(String columnName,
                                      SqlNode ctx)
Description copied from interface: SqlValidatorScope
Finds the table alias which is implicitly qualifying an unqualified column name. Throws an error if there is not exactly one table.

This method is only implemented in scopes (such as SelectScope) which can be the context for name-resolution. In scopes such as IdentifierNamespace, it throws UnsupportedOperationException.

Specified by:
findQualifyingTableName in interface SqlValidatorScope
Overrides:
findQualifyingTableName in class DelegatingScope
Parameters:
columnName - Column name
ctx - Validation context, to appear in any error thrown
Returns:
Table alias

resolve

public SqlValidatorNamespace resolve(String name,
                                     SqlValidatorScope[] ancestorOut,
                                     int[] offsetOut)
Description copied from interface: SqlValidatorScope
Looks up a node with a given name. Returns null if none is found.

Specified by:
resolve in interface SqlValidatorScope
Overrides:
resolve in class DelegatingScope
Parameters:
name - Name of node to find
ancestorOut - If not null, writes the ancestor scope here
offsetOut - If not null, writes the offset within the ancestor here

resolveColumn

public RelDataType resolveColumn(String columnName,
                                 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:
columnName - Name of column
ctx - Context for exception
Returns:
Type of column, if found and unambiguous; null if not found