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
Modifier and TypeFieldDescriptionfinal List<org.apache.calcite.sql.validate.ScopeChild>
List of childSqlValidatorNamespace
objects and their names.Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, resolved, validator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(SqlValidatorNamespace ns, String alias, boolean nullable) Registers a relation in this scope.void
findAliases
(Collection<SqlMoniker> result) Collects theSqlMoniker
s of all table aliases (uses of tables in query FROM clauses) available in this scope.void
findAllColumnNames
(List<SqlMoniker> result) Collects theSqlMoniker
s 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.boolean
isChildNullable
(int i) Whether the ith child namespace produces nullable result.void
resolve
(List<String> names, SqlNameMatcher nameMatcher, boolean deep, SqlValidatorScope.Resolved resolved) Looks up a node with a given name.@Nullable RelDataType
resolveColumn
(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, validateExpr
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.sql.validate.SqlValidatorScope
getNode, isMeasureRef, isWithin
-
Field Details
-
children
List of childSqlValidatorNamespace
objects and their names.
-
-
Constructor Details
-
ListScope
-
-
Method Details
-
addChild
Description copied from interface:SqlValidatorScope
Registers a relation in this scope.- Specified by:
addChild
in interfaceSqlValidatorScope
- Overrides:
addChild
in 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 DEPT
the namespace which corresponding to 'DEPT' is nullable.
- Parameters:
i
- The child index.- Returns:
- Whether it's nullable.
-
findAllColumnNames
Description copied from interface:SqlValidatorScope
Collects theSqlMoniker
s of all possible columns in this scope.- Specified by:
findAllColumnNames
in interfaceSqlValidatorScope
- Overrides:
findAllColumnNames
in classDelegatingScope
- Parameters:
result
- an array list of strings to add the result to
-
findAliases
Description copied from interface:SqlValidatorScope
Collects theSqlMoniker
s of all table aliases (uses of tables in query FROM clauses) available in this scope.- Specified by:
findAliases
in interfaceSqlValidatorScope
- Overrides:
findAliases
in classDelegatingScope
- Parameters:
result
- a list of monikers to add the result to
-
findQualifyingTableName
- Specified by:
findQualifyingTableName
in interfaceSqlValidatorScope
- Overrides:
findQualifyingTableName
in classDelegatingScope
-
findQualifyingTableNames
public Map<String,org.apache.calcite.sql.validate.ScopeChild> findQualifyingTableNames(String columnName, SqlNode ctx, SqlNameMatcher nameMatcher) Description copied from interface:SqlValidatorScope
Finds 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:
findQualifyingTableNames
in interfaceSqlValidatorScope
- Overrides:
findQualifyingTableNames
in 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:SqlValidatorScope
Looks up a node with a given name. Returns null if none is found.- Specified by:
resolve
in interfaceSqlValidatorScope
- Overrides:
resolve
in 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:SqlValidatorScope
Resolves 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:
resolveColumn
in interfaceSqlValidatorScope
- Overrides:
resolveColumn
in classDelegatingScope
- Parameters:
columnName
- Name of columnctx
- Context for exception- Returns:
- Type of column, if found and unambiguous; null if not found
-