Class SelectScope

  • All Implemented Interfaces:

    public class SelectScope
    extends ListScope
    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'.


    In the query

     SELECT expr1
     FROM t1,
         (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


    In the above query, there are 4 namespaces:

    • t1
    • t2
    • (SELECT expr2 FROM t3) AS q3
    • (SELECT expr3 FROM t4)
    See Also:
    • Field Detail

      • windowNames

        protected final java.util.List<java.lang.String> windowNames
      • expandedSelectList

        private java.util.List<SqlNode> expandedSelectList
      • orderList

        private SqlNodeList orderList
        List of column names which sort this scope. Empty if this scope is not sorted. Null if has not been computed yet.
      • windowParent

        private final SqlValidatorScope windowParent
        Scope to use to resolve windows
    • Constructor Detail

      • SelectScope

        SelectScope​(SqlValidatorScope parent,
                    SqlValidatorScope winParent,
                    SqlSelect select)
        Creates a scope corresponding to a SELECT clause.
        parent - Parent scope, must not be null
        winParent - Scope for window parent, may be null
        select - Select clause