Interface AggregatingScope

  • All Superinterfaces:
    All Known Implementing Classes:

    public interface AggregatingScope
    extends SqlValidatorScope
    An extension to the SqlValidatorScope interface which indicates that the scope is aggregating.

    A scope which is aggregating must implement this interface. Such a scope will return the same set of identifiers as its parent scope, but some of those identifiers may not be accessible because they are not in the GROUP BY clause.

    • Method Detail

      • checkAggregateExpr

        boolean checkAggregateExpr​(SqlNode expr,
                                   boolean deep)
        Checks whether an expression is constant within the GROUP BY clause. If the expression completely matches an expression in the GROUP BY clause, returns true. If the expression is constant within the group, but does not exactly match, returns false. If the expression is not constant, throws an exception. Examples:
        • If we are 'f(b, c)' in 'SELECT a + f(b, c) FROM t GROUP BY a', then the whole expression matches a group column. Return true.
        • Just an ordinary expression in a GROUP BY query, such as 'f(SUM(a), 1, b)' in 'SELECT f(SUM(a), 1, b) FROM t GROUP BY b'. Returns false.
        • Illegal expression, such as 'f(5, a, b)' in 'SELECT f(a, b) FROM t GROUP BY a'. Throws when it enounters the 'b' operand, because it is not in the group clause.