Interface SqlValidatorScope

    • Method Detail

      • getValidator

        SqlValidator getValidator()
        Returns the validator which created this scope.
      • getNode

        SqlNode getNode()
        Returns the root node of this scope. Never null.
      • resolve

        void resolve​(java.util.List<java.lang.String> names,
                     SqlNameMatcher nameMatcher,
                     boolean deep,
                     SqlValidatorScope.Resolved resolved)
        Looks up a node with a given name. Returns null if none is found.
        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
      • findQualifyingTableNames

        java.util.Map<java.lang.String,​ScopeChild> findQualifyingTableNames​(java.lang.String columnName,
                                                                                  SqlNode ctx,
                                                                                  SqlNameMatcher nameMatcher)
        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.

        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
      • findAllColumnNames

        void findAllColumnNames​(java.util.List<SqlMoniker> result)
        Collects the SqlMonikers of all possible columns in this scope.
        Parameters:
        result - an array list of strings to add the result to
      • findAliases

        void findAliases​(java.util.Collection<SqlMoniker> result)
        Collects the SqlMonikers of all table aliases (uses of tables in query FROM clauses) available in this scope.
        Parameters:
        result - a list of monikers to add the result to
      • fullyQualify

        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".
        Returns:
        A qualified identifier, never null
      • addChild

        void addChild​(SqlValidatorNamespace ns,
                      java.lang.String alias,
                      boolean nullable)
        Registers a relation in this scope.
        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
      • lookupWindow

        SqlWindow lookupWindow​(java.lang.String name)
        Finds a window with a given name. Returns null if not found.
      • getMonotonicity

        SqlMonotonicity getMonotonicity​(SqlNode expr)
        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.
      • getOrderList

        SqlNodeList getOrderList()
        Returns the expressions by which the rows in this scope are sorted. If the rows are unsorted, returns null.
      • resolveColumn

        RelDataType resolveColumn​(java.lang.String name,
                                  SqlNode ctx)
        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.

        Parameters:
        name - Name of column
        ctx - Context for exception
        Returns:
        Type of column, if found and unambiguous; null if not found
      • getOperandScope

        SqlValidatorScope getOperandScope​(SqlCall call)
        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.
        Parameters:
        call - Call
        Returns:
        Scope within which to validate arguments to call.
      • validateExpr

        void validateExpr​(SqlNode expr)
        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.
      • nullifyType

        RelDataType nullifyType​(SqlNode node,
                                RelDataType type)
        Converts the type of an expression to nullable, if the context warrants it.
      • isWithin

        default boolean isWithin​(SqlValidatorScope scope2)
        Returns whether this scope is enclosed within scope2 in such a way that it can see the contents of scope2.