public interface SqlValidatorScope
When validating an expression, say "foo"."bar", you first use the
resolve(java.util.List<java.lang.String>, org.apache.calcite.sql.validate.SqlNameMatcher, boolean, org.apache.calcite.sql.validate.SqlValidatorScope.Resolved) method of the scope where the expression is defined to
locate "foo". If successful, this returns a
namespace describing the type of the resulting
object.
| Modifier and Type | Interface and Description |
|---|---|
static class |
SqlValidatorScope.EmptyPath
A path that has no steps.
|
static class |
SqlValidatorScope.Path
A sequence of steps by which an identifier was resolved.
|
static class |
SqlValidatorScope.Resolve
A match found when looking up a name.
|
static interface |
SqlValidatorScope.Resolved
|
static class |
SqlValidatorScope.ResolvedImpl
Default implementation of
SqlValidatorScope.Resolved. |
static class |
SqlValidatorScope.Step
A step in resolving an identifier.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(SqlValidatorNamespace ns,
String alias,
boolean nullable)
Registers a relation in this scope.
|
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)
Deprecated.
|
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.
|
SqlNode |
getNode()
Returns the root node of 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.
|
@Nullable SqlValidatorNamespace |
getTableNamespace(List<String> names)
Deprecated.
|
SqlValidator |
getValidator()
Returns the validator which created this scope.
|
default boolean |
isWithin(@Nullable SqlValidatorScope scope2)
Returns whether this scope is enclosed within
scope2 in such
a way that it can see the contents of scope2. |
@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.
|
SqlValidator getValidator()
SqlNode getNode()
void resolve(List<String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved)
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@Deprecated Pair<String,SqlValidatorNamespace> findQualifyingTableName(String columnName, SqlNode ctx)
findQualifyingTableNames(String, SqlNode, SqlNameMatcher)Map<String,org.apache.calcite.sql.validate.ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher)
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.
columnName - Column namectx - Validation context, to appear in any error thrownnameMatcher - Name matchervoid findAllColumnNames(List<SqlMoniker> result)
SqlMonikers of all possible columns in this scope.result - an array list of strings to add the result tovoid findAliases(Collection<SqlMoniker> result)
SqlMonikers of all table aliases (uses of tables in
query FROM clauses) available in this scope.result - a list of monikers to add the result toSqlQualified fullyQualify(SqlIdentifier identifier)
void addChild(SqlValidatorNamespace ns, String alias, boolean nullable)
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@Nullable SqlWindow lookupWindow(String name)
SqlMonotonicity getMonotonicity(SqlNode expr)
@Nullable SqlNodeList getOrderList()
@Nullable RelDataType resolveColumn(String name, SqlNode ctx)
If it cannot find the column, returns null. If the column is
ambiguous, throws an error with context ctx.
name - Name of columnctx - Context for exceptionSqlValidatorScope getOperandScope(SqlCall call)
call - Callvoid validateExpr(SqlNode expr)
@Deprecated @Nullable SqlValidatorNamespace getTableNamespace(List<String> names)
resolveTable(List, SqlNameMatcher, Path, Resolved).void resolveTable(List<String> names, SqlNameMatcher nameMatcher, SqlValidatorScope.Path path, SqlValidatorScope.Resolved resolved)
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().
names - Name of table, may be qualified or fully-qualifiednameMatcher - Name matcherpath - List of names that we have traversed through so farRelDataType nullifyType(SqlNode node, RelDataType type)
default boolean isWithin(@Nullable SqlValidatorScope scope2)
scope2 in such
a way that it can see the contents of scope2.Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.