public abstract class DelegatingScope extends java.lang.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 |
Constructor and Description |
---|
DelegatingScope(SqlValidatorScope parent)
Creates a
DelegatingScope . |
Modifier and Type | Method and Description |
---|---|
void |
addChild(SqlValidatorNamespace ns,
java.lang.String alias,
boolean nullable)
Registers a relation in this scope.
|
protected void |
addColumnNames(SqlValidatorNamespace ns,
java.util.List<SqlMoniker> colNames) |
void |
findAliases(java.util.Collection<SqlMoniker> result)
Collects the
SqlMoniker s of all table aliases (uses of tables in
query FROM clauses) available in this scope. |
void |
findAllColumnNames(java.util.List<SqlMoniker> result)
Collects the
SqlMoniker s of all possible columns in this scope. |
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.
|
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.
|
SqlNodeList |
getOrderList()
Returns the expressions by which the rows in this scope are sorted.
|
SqlValidatorScope |
getParent()
Returns the parent scope of this
DelegatingScope . |
SqlValidatorNamespace |
getTableNamespace(java.util.List<java.lang.String> names) |
SqlValidator |
getValidator()
Returns the validator which created this scope.
|
private boolean |
hasAmbiguousField(RelDataType rowType,
RelDataTypeField field,
java.lang.String columnName,
SqlNameMatcher nameMatcher)
Returns whether
rowType contains more than one star column or
fields with the same name, which implies ambiguous column. |
SqlWindow |
lookupWindow(java.lang.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(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 name,
SqlNode ctx)
Resolves a single identifier to a column, and returns the datatype of
that column.
|
(package private) void |
resolveInNamespace(SqlValidatorNamespace ns,
boolean nullable,
java.util.List<java.lang.String> names,
SqlNameMatcher nameMatcher,
SqlValidatorScope.Path path,
SqlValidatorScope.Resolved resolved)
If a record type allows implicit references to fields, recursively looks
into the fields.
|
void |
resolveTable(java.util.List<java.lang.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, wait
getNode, isWithin
protected final SqlValidatorScope parent
This is never null: at the top of the tree, it is an
EmptyScope
.
protected final SqlValidatorImpl validator
DelegatingScope(SqlValidatorScope parent)
DelegatingScope
.parent
- Parent scopepublic void addChild(SqlValidatorNamespace ns, java.lang.String alias, boolean nullable)
SqlValidatorScope
addChild
in interface SqlValidatorScope
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 joinpublic void resolve(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved)
SqlValidatorScope
resolve
in interface SqlValidatorScope
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 findvoid resolveInNamespace(SqlValidatorNamespace ns, boolean nullable, java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher, SqlValidatorScope.Path path, SqlValidatorScope.Resolved resolved)
protected void addColumnNames(SqlValidatorNamespace ns, java.util.List<SqlMoniker> colNames)
public void findAllColumnNames(java.util.List<SqlMoniker> result)
SqlValidatorScope
SqlMoniker
s of all possible columns in this scope.findAllColumnNames
in interface SqlValidatorScope
result
- an array list of strings to add the result topublic void findAliases(java.util.Collection<SqlMoniker> result)
SqlValidatorScope
SqlMoniker
s of all table aliases (uses of tables in
query FROM clauses) available in this scope.findAliases
in interface SqlValidatorScope
result
- a list of monikers to add the result topublic Pair<java.lang.String,SqlValidatorNamespace> findQualifyingTableName(java.lang.String columnName, SqlNode ctx)
findQualifyingTableName
in interface SqlValidatorScope
public java.util.Map<java.lang.String,ScopeChild> findQualifyingTableNames(java.lang.String columnName, SqlNode ctx, SqlNameMatcher nameMatcher)
SqlValidatorScope
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
.
findQualifyingTableNames
in interface SqlValidatorScope
columnName
- Column namectx
- Validation context, to appear in any error thrownnameMatcher
- Name matcherpublic RelDataType resolveColumn(java.lang.String name, SqlNode ctx)
SqlValidatorScope
If it cannot find the column, returns null. If the column is
ambiguous, throws an error with context ctx
.
resolveColumn
in interface SqlValidatorScope
name
- Name of columnctx
- Context for exceptionpublic RelDataType nullifyType(SqlNode node, RelDataType type)
SqlValidatorScope
nullifyType
in interface SqlValidatorScope
public SqlValidatorNamespace getTableNamespace(java.util.List<java.lang.String> names)
getTableNamespace
in interface SqlValidatorScope
public void resolveTable(java.util.List<java.lang.String> names, SqlNameMatcher nameMatcher, SqlValidatorScope.Path path, SqlValidatorScope.Resolved resolved)
SqlValidatorScope
SqlValidatorScope.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 SqlValidatorScope
names
- 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)
SqlValidatorScope
getOperandScope
in interface SqlValidatorScope
call
- Callpublic SqlValidator getValidator()
SqlValidatorScope
getValidator
in interface SqlValidatorScope
public SqlQualified fullyQualify(SqlIdentifier identifier)
If the identifier cannot be resolved, throws. Never returns null.
fullyQualify
in interface SqlValidatorScope
public void validateExpr(SqlNode expr)
SqlValidatorScope
validateExpr
in interface SqlValidatorScope
public SqlWindow lookupWindow(java.lang.String name)
SqlValidatorScope
lookupWindow
in interface SqlValidatorScope
public SqlMonotonicity getMonotonicity(SqlNode expr)
SqlValidatorScope
getMonotonicity
in interface SqlValidatorScope
public SqlNodeList getOrderList()
SqlValidatorScope
getOrderList
in interface SqlValidatorScope
private boolean hasAmbiguousField(RelDataType rowType, RelDataTypeField field, java.lang.String columnName, SqlNameMatcher nameMatcher)
rowType
contains more than one star column or
fields with the same name, which implies ambiguous column.public SqlValidatorScope getParent()
DelegatingScope
.Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.