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.SqlValidatorScope[], int[]) 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 | Method and Description |
|---|---|
void |
addChild(SqlValidatorNamespace ns,
String alias)
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)
Finds the table alias which is 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.
|
SqlNodeList |
getOrderList()
Returns the expressions by which the rows in this scope are sorted.
|
SqlValidatorNamespace |
getTableNamespace(List<String> names)
Looks up a table in this scope from its name.
|
SqlValidator |
getValidator()
Returns the validator which created this scope.
|
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.
|
SqlValidatorNamespace |
resolve(List<String> names,
SqlValidatorScope[] ancestorOut,
int[] offsetOut)
Looks up a node with a given name.
|
RelDataType |
resolveColumn(String name,
SqlNode ctx)
Resolves a single identifier to a column, and returns the datatype of
that column.
|
void |
validateExpr(SqlNode expr)
Performs any scope-specific validation of an expression.
|
SqlValidator getValidator()
SqlNode getNode()
SqlValidatorNamespace resolve(List<String> names, SqlValidatorScope[] ancestorOut, int[] offsetOut)
names - Name of node to findancestorOut - If not null, writes the ancestor scope hereoffsetOut - If not null, writes the offset within the ancestor herePair<String,SqlValidatorNamespace> findQualifyingTableName(String columnName, SqlNode ctx)
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 thrownvoid 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)
ns - Namespace representing the result-columns of the relationalias - Alias with which to reference the relation, must not be nullSqlWindow lookupWindow(String name)
SqlMonotonicity getMonotonicity(SqlNode expr)
SqlNodeList getOrderList()
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)
SqlValidatorNamespace getTableNamespace(List<String> names)
TableNamespace that wraps it. If the "table" is defined in a
WITH clause it may be a query, not a table after all.names - Name of table, may be qualified or fully-qualifiedRelDataType nullifyType(SqlNode node, RelDataType type)
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.