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:
JoinScope,MatchRecognizeScope,OverScope,PivotScope,SelectScope,SqlLambdaScope,UnpivotScope
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
FieldsModifier and TypeFieldDescriptionfinal List<org.apache.calcite.sql.validate.ScopeChild>List of childSqlValidatorNamespaceobjects and their names.Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, resolved, validator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(SqlValidatorNamespace ns, String alias, boolean nullable) Registers a relation in this scope.voidfindAliases(Collection<SqlMoniker> result) Collects theSqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.voidfindAllColumnNames(List<SqlMoniker> result) Collects theSqlMonikers of all possible columns in this scope.findQualifyingTableName(String columnName, SqlNode ctx) findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher) Finds all table aliases which are implicitly qualifying an unqualified column name.Returns an immutable list of child namespaces.booleanisChildNullable(int i) Whether the ith child namespace produces nullable result.voidresolve(List<String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved) Looks up a node with a given name.@Nullable RelDataTyperesolveColumn(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, analyze, fullyQualify, getMonotonicity, getOperandScope, getOrderList, getParent, getTableNamespace, getValidator, lookupWindow, nullifyType, qualifyUsingAlias, resolveTable, validateExprMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
getNode, isMeasureRef, isWithin
-
Field Details
-
children
List of childSqlValidatorNamespaceobjects and their names.
-
-
Constructor Details
-
ListScope
-
-
Method Details
-
addChild
Description copied from interface:SqlValidatorScopeRegisters a relation in this scope.- Specified by:
addChildin interfaceSqlValidatorScope- Overrides:
addChildin 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
Returns an immutable list of child namespaces.- Returns:
- list of child namespaces
-
isChildNullable
public boolean isChildNullable(int i) Whether the ith child namespace produces nullable result.For example, in below query,
SELECT * FROM EMPS LEFT OUTER JOIN DEPTthe namespace which corresponding to 'DEPT' is nullable.
- Parameters:
i- The child index.- Returns:
- Whether it's nullable.
-
findAllColumnNames
Description copied from interface:SqlValidatorScopeCollects theSqlMonikers of all possible columns in this scope.- Specified by:
findAllColumnNamesin interfaceSqlValidatorScope- Overrides:
findAllColumnNamesin classDelegatingScope- Parameters:
result- an array list of strings to add the result to
-
findAliases
Description copied from interface:SqlValidatorScopeCollects theSqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.- Specified by:
findAliasesin interfaceSqlValidatorScope- Overrides:
findAliasesin classDelegatingScope- Parameters:
result- a list of monikers to add the result to
-
findQualifyingTableName
- Specified by:
findQualifyingTableNamein interfaceSqlValidatorScope- Overrides:
findQualifyingTableNamein classDelegatingScope
-
findQualifyingTableNames
public Map<String,org.apache.calcite.sql.validate.ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher) Description copied from interface:SqlValidatorScopeFinds 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:
findQualifyingTableNamesin interfaceSqlValidatorScope- Overrides:
findQualifyingTableNamesin 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(List<String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved) Description copied from interface:SqlValidatorScopeLooks up a node with a given name. Adds the match(es) to the resolved if found.- Specified by:
resolvein interfaceSqlValidatorScope- Overrides:
resolvein 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
Description copied from interface:SqlValidatorScopeResolves 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:
resolveColumnin interfaceSqlValidatorScope- Overrides:
resolveColumnin classDelegatingScope- Parameters:
columnName- Name of columnctx- Context for exception- Returns:
- Type of column, if found and unambiguous; null if not found
-