Class OrderByScope

  • All Implemented Interfaces:

    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 x

    is valid.

    • Method Detail

      • getNode

        public SqlNode getNode()
        Description copied from interface: SqlValidatorScope
        Returns the root node of this scope. Never null.
      • 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 interface SqlValidatorScope
        fullyQualify in class DelegatingScope
        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 have name as their implicit (e.g. 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 interface SqlValidatorScope
        resolveColumn in class DelegatingScope
        name - Name of column
        ctx - Context for exception
        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 interface SqlValidatorScope
        validateExpr in class DelegatingScope