public abstract class DelegatingScope extends Object implements SqlValidatorScope
SqlValidatorScope.EmptyPath, SqlValidatorScope.Path, SqlValidatorScope.Resolve, SqlValidatorScope.Resolved, SqlValidatorScope.ResolvedImpl, SqlValidatorScope.Step| Modifier and Type | Field and Description |
|---|---|
protected SqlValidatorScope |
parent
Parent scope.
|
protected SqlValidatorImpl |
validator |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(SqlValidatorNamespace ns,
String alias,
boolean nullable)
Registers a relation in this scope.
|
protected void |
addColumnNames(SqlValidatorNamespace ns,
List<SqlMoniker> colNames) |
void |
findAliases(Collection<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. |
Pair<String,SqlValidatorNamespace> |
findQualifyingTableName(String columnName,
SqlNode ctx) |
Map<String,org.apache.calcite.sql.validate.ScopeChild> |
findQualifyingTableNames(String columnName,
SqlNode ctx,
SqlNameMatcher nameMatcher)
Finds all table aliases which are implicitly qualifying an unqualified
column name.
|
SqlQualified |
fullyQualify(SqlIdentifier identifier)
Converts an identifier into a fully-qualified identifier.
|
SqlMonotonicity |
getMonotonicity(SqlNode expr)
Returns whether an expression is monotonic in this scope.
|
SqlValidatorScope |
getOperandScope(SqlCall call)
Returns the scope within which operands to a call are to be validated.
|
@Nullable SqlNodeList |
getOrderList()
Returns the expressions by which the rows in this scope are sorted.
|
SqlValidatorScope |
getParent()
Returns the parent scope of this
DelegatingScope. |
@Nullable SqlValidatorNamespace |
getTableNamespace(List<String> names) |
SqlValidator |
getValidator()
Returns the validator which created this scope.
|
@Nullable SqlWindow |
lookupWindow(String name)
Finds a window with a given name.
|
RelDataType |
nullifyType(SqlNode node,
RelDataType type)
Converts the type of an expression to nullable, if the context
warrants it.
|
void |
resolve(List<String> names,
SqlNameMatcher nameMatcher,
boolean deep,
SqlValidatorScope.Resolved resolved)
Looks up a node with a given name.
|
@Nullable RelDataType |
resolveColumn(String name,
SqlNode ctx)
Resolves a single identifier to a column, and returns the datatype of
that column.
|
void |
resolveTable(List<String> names,
SqlNameMatcher nameMatcher,
SqlValidatorScope.Path path,
SqlValidatorScope.Resolved resolved)
Looks up a table in this scope from its name.
|
void |
validateExpr(SqlNode expr)
Performs any scope-specific validation of an expression.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetNode, isWithinprotected final SqlValidatorScope parent
This is never null: at the top of the tree, it is an
EmptyScope.
protected final SqlValidatorImpl validator
public void addChild(SqlValidatorNamespace ns, String alias, boolean nullable)
SqlValidatorScopeaddChild in interface SqlValidatorScopens - 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 joinpublic void resolve(List<String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved)
SqlValidatorScoperesolve in interface SqlValidatorScopenames - 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 findprotected void addColumnNames(SqlValidatorNamespace ns, List<SqlMoniker> colNames)
public void findAllColumnNames(List<SqlMoniker> result)
SqlValidatorScopeSqlMonikers of all possible columns in this scope.findAllColumnNames in interface SqlValidatorScoperesult - an array list of strings to add the result topublic void findAliases(Collection<SqlMoniker> result)
SqlValidatorScopeSqlMonikers of all table aliases (uses of tables in
query FROM clauses) available in this scope.findAliases in interface SqlValidatorScoperesult - a list of monikers to add the result topublic Pair<String,SqlValidatorNamespace> findQualifyingTableName(String columnName, SqlNode ctx)
findQualifyingTableName in interface SqlValidatorScopepublic Map<String,org.apache.calcite.sql.validate.ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher)
SqlValidatorScopeThis 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.
findQualifyingTableNames in interface SqlValidatorScopecolumnName - Column namectx - Validation context, to appear in any error thrownnameMatcher - Name matcherpublic @Nullable RelDataType resolveColumn(String name, SqlNode ctx)
SqlValidatorScopeIf it cannot find the column, returns null. If the column is
ambiguous, throws an error with context ctx.
resolveColumn in interface SqlValidatorScopename - Name of columnctx - Context for exceptionpublic RelDataType nullifyType(SqlNode node, RelDataType type)
SqlValidatorScopenullifyType in interface SqlValidatorScopepublic @Nullable SqlValidatorNamespace getTableNamespace(List<String> names)
getTableNamespace in interface SqlValidatorScopepublic void resolveTable(List<String> names, SqlNameMatcher nameMatcher, SqlValidatorScope.Path path, SqlValidatorScope.Resolved resolved)
SqlValidatorScopeSqlValidatorScope.resolve(List, SqlNameMatcher, boolean, Resolved).
TableNamespace that wraps it. If the "table" is defined in a
WITH clause it may be a query, not a table after all.
The name matcher is not null, and one typically uses
SqlValidatorCatalogReader.nameMatcher().
resolveTable in interface SqlValidatorScopenames - Name of table, may be qualified or fully-qualifiednameMatcher - Name matcherpath - List of names that we have traversed through so farpublic SqlValidatorScope getOperandScope(SqlCall call)
SqlValidatorScopegetOperandScope in interface SqlValidatorScopecall - Callpublic SqlValidator getValidator()
SqlValidatorScopegetValidator in interface SqlValidatorScopepublic SqlQualified fullyQualify(SqlIdentifier identifier)
If the identifier cannot be resolved, throws. Never returns null.
fullyQualify in interface SqlValidatorScopepublic void validateExpr(SqlNode expr)
SqlValidatorScopevalidateExpr in interface SqlValidatorScopepublic @Nullable SqlWindow lookupWindow(String name)
SqlValidatorScopelookupWindow in interface SqlValidatorScopepublic SqlMonotonicity getMonotonicity(SqlNode expr)
SqlValidatorScopegetMonotonicity in interface SqlValidatorScopepublic @Nullable SqlNodeList getOrderList()
SqlValidatorScopegetOrderList in interface SqlValidatorScopepublic SqlValidatorScope getParent()
DelegatingScope.Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.