Class Scope


  • @Immutable
    public class Scope
    extends Object
    • Method Detail

      • create

        public static Scope create()
      • getQueryBoundaryScope

        public Scope getQueryBoundaryScope()
      • getOuterQueryParent

        public Optional<Scope> getOuterQueryParent()
      • hasOuterParent

        public boolean hasOuterParent​(Scope parent)
      • getLocalScopeFieldCount

        public int getLocalScopeFieldCount()
      • getRelationId

        public RelationId getRelationId()
      • resolveAsteriskedIdentifierChainBasis

        public Optional<Scope.AsteriskedIdentifierChainBasis> resolveAsteriskedIdentifierChainBasis​(QualifiedName identifierChain,
                                                                                                    AllColumns selectItem)
        This method analyzes asterisked identifier chain in 'all fields reference', according to SQL standard. The following rules are applied: 1. if the identifier chain's length is lower than 4, it is attempted to resolve it as a table reference, either in the local scope or in outer scope. 2. if the identifier chain's length is greater than 1, it is attempted to match the chain's prefix of length 2 to a field of type Row, either in the local scope or in outer scope. Any available match in the innermost scope is picked and the 'identifier chain basis' is defined. If more than one basis is defined, it results in a failure (ambiguous identifier chain).

        NOTE: only ambiguity between table reference and field reference is currently detected. If two or more tables in the same scope match the identifier chain, they are indistinguishable in current Scope implementation, and such query results in returning fields from all of those tables. If two or more fields in the same scope match the identifier chain, such query will fail later during analysis.

        NOTE: Although references to outer scope tables are found, referencing all fields from outer scope tables is not yet supported.

      • isLocalScope

        public boolean isLocalScope​(Scope other)
      • isColumnReference

        public boolean isColumnReference​(QualifiedName name)