Package org.apache.calcite.sql.validate
Class ListScope
- java.lang.Object
-
- org.apache.calcite.sql.validate.DelegatingScope
-
- org.apache.calcite.sql.validate.ListScope
-
- All Implemented Interfaces:
SqlValidatorScope
- Direct Known Subclasses:
CollectScope
,JoinScope
,MatchRecognizeScope
,OverScope
,SelectScope
,TableScope
,WithScope
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
SqlValidatorScope.EmptyPath, SqlValidatorScope.Path, SqlValidatorScope.Resolve, SqlValidatorScope.Resolved, SqlValidatorScope.ResolvedImpl, SqlValidatorScope.Step
-
-
Field Summary
Fields Modifier and Type Field Description java.util.List<ScopeChild>
children
List of childSqlValidatorNamespace
objects and their names.-
Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, validator
-
-
Constructor Summary
Constructors Constructor Description ListScope(SqlValidatorScope parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(SqlValidatorNamespace ns, java.lang.String alias, boolean nullable)
Registers a relation in this scope.void
findAliases(java.util.Collection<SqlMoniker> result)
Collects theSqlMoniker
s of all table aliases (uses of tables in query FROM clauses) available in this scope.void
findAllColumnNames(java.util.List<SqlMoniker> result)
Collects theSqlMoniker
s of all possible columns in this scope.private ScopeChild
findChild(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher)
Pair<java.lang.String,SqlValidatorNamespace>
findQualifyingTableName(java.lang.String columnName, SqlNode ctx)
java.util.Map<java.lang.String,ScopeChild>
findQualifyingTableNames(java.lang.String columnName, SqlNode ctx, SqlNameMatcher nameMatcher)
Finds all table aliases which are implicitly qualifying an unqualified column name.(package private) java.util.List<java.lang.String>
getChildNames()
Returns an immutable list of child names.java.util.List<SqlValidatorNamespace>
getChildren()
Returns an immutable list of child namespaces.void
resolve(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved)
Looks up a node with a given name.RelDataType
resolveColumn(java.lang.String columnName, SqlNode ctx)
Resolves a single identifier to a column, and returns the datatype of that column.-
Methods inherited from class org.apache.calcite.sql.validate.DelegatingScope
addColumnNames, fullyQualify, getMonotonicity, getOperandScope, getOrderList, getParent, getTableNamespace, getValidator, lookupWindow, nullifyType, resolveInNamespace, resolveTable, validateExpr
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
getNode, isWithin
-
-
-
-
Field Detail
-
children
public final java.util.List<ScopeChild> children
List of childSqlValidatorNamespace
objects and their names.
-
-
Constructor Detail
-
ListScope
public ListScope(SqlValidatorScope parent)
-
-
Method Detail
-
addChild
public void addChild(SqlValidatorNamespace ns, java.lang.String alias, boolean nullable)
Description copied from interface:SqlValidatorScope
Registers a relation in this scope.- Specified by:
addChild
in interfaceSqlValidatorScope
- Overrides:
addChild
in classDelegatingScope
- Parameters:
ns
- Namespace representing the result-columns of the relationalias
- Alias with which to reference the relation, must not be nullnullable
- Whether this is a null-generating side of a join
-
getChildren
public java.util.List<SqlValidatorNamespace> getChildren()
Returns an immutable list of child namespaces.- Returns:
- list of child namespaces
-
getChildNames
java.util.List<java.lang.String> getChildNames()
Returns an immutable list of child names.- Returns:
- list of child namespaces
-
findChild
private ScopeChild findChild(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher)
-
findAllColumnNames
public void findAllColumnNames(java.util.List<SqlMoniker> result)
Description copied from interface:SqlValidatorScope
Collects theSqlMoniker
s of all possible columns in this scope.- Specified by:
findAllColumnNames
in interfaceSqlValidatorScope
- Overrides:
findAllColumnNames
in classDelegatingScope
- Parameters:
result
- an array list of strings to add the result to
-
findAliases
public void findAliases(java.util.Collection<SqlMoniker> result)
Description copied from interface:SqlValidatorScope
Collects theSqlMoniker
s of all table aliases (uses of tables in query FROM clauses) available in this scope.- Specified by:
findAliases
in interfaceSqlValidatorScope
- Overrides:
findAliases
in classDelegatingScope
- Parameters:
result
- a list of monikers to add the result to
-
findQualifyingTableName
public Pair<java.lang.String,SqlValidatorNamespace> findQualifyingTableName(java.lang.String columnName, SqlNode ctx)
- Specified by:
findQualifyingTableName
in interfaceSqlValidatorScope
- Overrides:
findQualifyingTableName
in classDelegatingScope
-
findQualifyingTableNames
public java.util.Map<java.lang.String,ScopeChild> findQualifyingTableNames(java.lang.String columnName, SqlNode ctx, SqlNameMatcher nameMatcher)
Description copied from interface:SqlValidatorScope
Finds all table aliases which are implicitly qualifying an unqualified column name.This method is only implemented in scopes (such as
SelectScope
) which can be the context for name-resolution. In scopes such asIdentifierNamespace
, it throwsUnsupportedOperationException
.- Specified by:
findQualifyingTableNames
in interfaceSqlValidatorScope
- Overrides:
findQualifyingTableNames
in classDelegatingScope
- Parameters:
columnName
- Column namectx
- Validation context, to appear in any error thrownnameMatcher
- Name matcher- Returns:
- Map of applicable table alias and namespaces, never null, empty if no aliases found
-
resolve
public void resolve(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved)
Description copied from interface:SqlValidatorScope
Looks up a node with a given name. Returns null if none is found.- Specified by:
resolve
in interfaceSqlValidatorScope
- Overrides:
resolve
in classDelegatingScope
- Parameters:
names
- Name of node to find, maybe partially or fully qualifiednameMatcher
- Name matcherdeep
- Whether to look more than one level deepresolved
- Callback wherein to write the match(es) we find
-
resolveColumn
public RelDataType resolveColumn(java.lang.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 interfaceSqlValidatorScope
- Overrides:
resolveColumn
in classDelegatingScope
- Parameters:
columnName
- Name of columnctx
- Context for exception- Returns:
- Type of column, if found and unambiguous; null if not found
-
-