Package org.apache.calcite.sql.validate
Class OrderByScope
- java.lang.Object
-
- org.apache.calcite.sql.validate.DelegatingScope
-
- org.apache.calcite.sql.validate.OrderByScope
-
- All Implemented Interfaces:
SqlValidatorScope
public class OrderByScope extends DelegatingScope
Represents the name-resolution context for expressions in an ORDER BY clause.In some dialects of SQL, the ORDER BY clause can reference column aliases in the SELECT clause. For example, the query
SELECT empno AS x
FROM emp
ORDER BY xis valid.
-
-
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 Modifier and Type Field Description private SqlNodeList
orderList
private SqlSelect
select
-
Fields inherited from class org.apache.calcite.sql.validate.DelegatingScope
parent, validator
-
-
Constructor Summary
Constructors Constructor Description OrderByScope(SqlValidatorScope parent, SqlNodeList orderList, SqlSelect select)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
aliasCount(SqlNameMatcher nameMatcher, java.lang.String name)
Returns the number of columns in the SELECT clause that havename
as their implicit (e.g.void
findAllColumnNames(java.util.List<SqlMoniker> result)
Collects theSqlMoniker
s of all possible columns in this scope.SqlQualified
fullyQualify(SqlIdentifier identifier)
Converts an identifier into a fully-qualified identifier.SqlNode
getNode()
Returns the root node of this scope.RelDataType
resolveColumn(java.lang.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.-
Methods inherited from class org.apache.calcite.sql.validate.DelegatingScope
addChild, addColumnNames, findAliases, findQualifyingTableName, findQualifyingTableNames, getMonotonicity, getOperandScope, getOrderList, getParent, getTableNamespace, getValidator, lookupWindow, nullifyType, resolve, resolveInNamespace, resolveTable
-
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
isWithin
-
-
-
-
Field Detail
-
orderList
private final SqlNodeList orderList
-
select
private final SqlSelect select
-
-
Constructor Detail
-
OrderByScope
OrderByScope(SqlValidatorScope parent, SqlNodeList orderList, SqlSelect select)
-
-
Method Detail
-
getNode
public SqlNode getNode()
Description copied from interface:SqlValidatorScope
Returns the root node of this scope. Never null.
-
findAllColumnNames
public void findAllColumnNames(java.util.List<SqlMoniker> result)
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
-
fullyQualify
public SqlQualified fullyQualify(SqlIdentifier identifier)
Description copied from class:DelegatingScope
Converts an identifier into a fully-qualified identifier. For example, the "empno" in "select empno from emp natural join dept" becomes "emp.empno".If the identifier cannot be resolved, throws. Never returns null.
- Specified by:
fullyQualify
in interfaceSqlValidatorScope
- Overrides:
fullyQualify
in classDelegatingScope
- Returns:
- A qualified identifier, never null
-
aliasCount
private int aliasCount(SqlNameMatcher nameMatcher, java.lang.String name)
Returns the number of columns in the SELECT clause that havename
as their implicit (e.g.t.name
) or explicit (e.g.t.c as name
) alias.
-
resolveColumn
public RelDataType resolveColumn(java.lang.String name, SqlNode ctx)
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:
name
- Name of columnctx
- Context for exception- Returns:
- Type of column, if found and unambiguous; null if not found
-
validateExpr
public void validateExpr(SqlNode expr)
Description copied from interface:SqlValidatorScope
Performs any scope-specific validation of an expression. For example, an aggregating scope requires that expressions are valid aggregations. The expression has already been validated.- Specified by:
validateExpr
in interfaceSqlValidatorScope
- Overrides:
validateExpr
in classDelegatingScope
-
-