Class SelectScope

All Implemented Interfaces:
SqlValidatorScope

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'.

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: