Package org.apache.calcite.sql.validate
Class SelectScope
java.lang.Object
org.apache.calcite.sql.validate.DelegatingScope
org.apache.calcite.sql.validate.ListScope
org.apache.calcite.sql.validate.SelectScope
- All Implemented Interfaces:
SqlValidatorScope
The name-resolution scope of a SELECT clause. The objects visible are those
in the FROM clause, and objects inherited from the parent scope.
This object is both a SqlValidatorScope
and a
SqlValidatorNamespace
. In the query
SELECT name FROM ( SELECT * FROM emp WHERE gender = 'F')
we need to use the SelectScope
as a
SqlValidatorNamespace
when resolving 'name', and
as a SqlValidatorScope
when resolving 'gender'.
Scopes
In the query
SELECT expr1 FROM t1, t2, (SELECT expr2 FROM t3) AS q3 WHERE c1 IN (SELECT expr3 FROM t4) ORDER BY expr4
The scopes available at various points of the query are as follows:
- expr1 can see t1, t2, q3
- expr2 can see t3
- expr3 can see t4, t1, t2
- expr4 can see t1, t2, q3, plus (depending upon the dialect) any aliases defined in the SELECT clause
Namespaces
In the above query, there are 4 namespaces:
- t1
- t2
- (SELECT expr2 FROM t3) AS q3
- (SELECT expr3 FROM t4)
- See Also:
-
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
Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, resolved, validator
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWindowName
(String winName) boolean
existingWindowName
(String winName) getMonotonicity
(SqlNode expr) Returns whether an expression is monotonic in this scope.getNode()
Returns the root node of this scope.Returns the expressions by which the rows in this scope are sorted.@Nullable SqlValidatorTable
getTable()
@Nullable SqlWindow
lookupWindow
(String name) Finds a window with a given name.void
setExpandedSelectList
(@Nullable List<SqlNode> selectList) Methods inherited from class org.apache.calcite.sql.validate.ListScope
addChild, findAliases, findAllColumnNames, findQualifyingTableName, findQualifyingTableNames, getChildren, isChildNullable, resolve, resolveColumn
Methods inherited from class org.apache.calcite.sql.validate.DelegatingScope
addColumnNames, analyze, fullyQualify, getOperandScope, getParent, getTableNamespace, getValidator, 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
isMeasureRef, isWithin
-
Field Details
-
windowNames
-
-
Method Details
-
getTable
-
getNode
Description copied from interface:SqlValidatorScope
Returns the root node of this scope. Never null. -
lookupWindow
Description copied from interface:SqlValidatorScope
Finds a window with a given name. Returns null if not found.- Specified by:
lookupWindow
in interfaceSqlValidatorScope
- Overrides:
lookupWindow
in classDelegatingScope
-
getMonotonicity
Description copied from interface:SqlValidatorScope
Returns whether an expression is monotonic in this scope. For example, if the scope has previously been sorted by columns X, Y, then X is monotonic in this scope, but Y is not.- Specified by:
getMonotonicity
in interfaceSqlValidatorScope
- Overrides:
getMonotonicity
in classDelegatingScope
-
getOrderList
Description copied from interface:SqlValidatorScope
Returns the expressions by which the rows in this scope are sorted. If the rows are unsorted, returns null.- Specified by:
getOrderList
in interfaceSqlValidatorScope
- Overrides:
getOrderList
in classDelegatingScope
-
addWindowName
-
existingWindowName
-
getExpandedSelectList
-
setExpandedSelectList
-