Class DelegatingScope

    • Field Detail

      • parent

        protected final SqlValidatorScope parent
        Parent scope. This is where to look next to resolve an identifier; it is not always the parent object in the parse tree.

        This is never null: at the top of the tree, it is an EmptyScope.

    • Constructor Detail

      • DelegatingScope

        DelegatingScope​(SqlValidatorScope parent)
        Creates a DelegatingScope.
        Parameters:
        parent - Parent scope
    • Method Detail

      • addChild

        public void addChild​(SqlValidatorNamespace ns,
                             java.lang.String alias,
                             boolean nullable)
        Description copied from interface: SqlValidatorScope
        Registers a relation in this scope.
        Specified by:
        addChild in interface SqlValidatorScope
        Parameters:
        ns - Namespace representing the result-columns of the relation
        alias - Alias with which to reference the relation, must not be null
        nullable - Whether this is a null-generating side of a join
      • resolve

        public void resolve​(java.util.List<java.lang.String> names,
                            SqlNameMatcher nameMatcher,
                            boolean deep,
                            SqlValidatorScope.Resolved resolved)
        Description copied from interface: SqlValidatorScope
        Looks up a node with a given name. Returns null if none is found.
        Specified by:
        resolve in interface SqlValidatorScope
        Parameters:
        names - Name of node to find, maybe partially or fully qualified
        nameMatcher - Name matcher
        deep - Whether to look more than one level deep
        resolved - Callback wherein to write the match(es) we find
      • findAliases

        public void findAliases​(java.util.Collection<SqlMoniker> result)
        Description copied from interface: SqlValidatorScope
        Collects the SqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.
        Specified by:
        findAliases in interface SqlValidatorScope
        Parameters:
        result - a list of monikers to add the result to
      • findQualifyingTableNames

        public java.util.Map<java.lang.String,​ScopeChild> findQualifyingTableNames​(java.lang.String columnName,
                                                                                         SqlNode ctx,
                                                                                         SqlNameMatcher nameMatcher)
        Description copied from interface: SqlValidatorScope
        Finds all table aliases which are implicitly qualifying an unqualified column name.

        This method is only implemented in scopes (such as SelectScope) which can be the context for name-resolution. In scopes such as IdentifierNamespace, it throws UnsupportedOperationException.

        Specified by:
        findQualifyingTableNames in interface SqlValidatorScope
        Parameters:
        columnName - Column name
        ctx - Validation context, to appear in any error thrown
        nameMatcher - Name matcher
        Returns:
        Map of applicable table alias and namespaces, never null, empty if no aliases found
      • 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
        Parameters:
        name - Name of column
        ctx - Context for exception
        Returns:
        Type of column, if found and unambiguous; null if not found
      • getOperandScope

        public SqlValidatorScope getOperandScope​(SqlCall call)
        Description copied from interface: SqlValidatorScope
        Returns the scope within which operands to a call are to be validated. Usually it is this scope, but when the call is to an aggregate function and this is an aggregating scope, it will be a a different scope.
        Specified by:
        getOperandScope in interface SqlValidatorScope
        Parameters:
        call - Call
        Returns:
        Scope within which to validate arguments to call.
      • fullyQualify

        public SqlQualified fullyQualify​(SqlIdentifier identifier)
        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
        Returns:
        A qualified identifier, never null
      • 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
      • getMonotonicity

        public SqlMonotonicity getMonotonicity​(SqlNode expr)
        Description copied from interface: SqlValidatorScope
        Returns whether an expression is monotonic in this scope. For example, if the scope has previously been sorted by columns X, Y, then X is monotonic in this scope, but Y is not.
        Specified by:
        getMonotonicity in interface SqlValidatorScope
      • hasAmbiguousField

        private boolean hasAmbiguousField​(RelDataType rowType,
                                          RelDataTypeField field,
                                          java.lang.String columnName,
                                          SqlNameMatcher nameMatcher)
        Returns whether rowType contains more than one star column or fields with the same name, which implies ambiguous column.
      • getParent

        public SqlValidatorScope getParent()
        Returns the parent scope of this DelegatingScope.