public SelectScope getRawSelectScope(SqlSelect select) { SqlValidatorScope scope = getSelectScope(select); if (scope instanceof AggregatingSelectScope) { scope = ((AggregatingSelectScope) scope).getParent(); } return (SelectScope) scope; }
if (isAggregate(select)) { aggScope = new AggregatingSelectScope(selectScope, select, false); selectScopes.put(select, aggScope); } else { new AggregatingSelectScope(selectScope, select, true);
public void validateExpr(SqlNode expr) { checkAggregateExpr(expr, true); }
public boolean checkAggregateExpr(SqlNode expr, boolean deep) { // Fully-qualify any identifiers in expr. if (deep) { expr = validator.expand(expr, this); } // Make sure expression is valid, throws if not. Pair<ImmutableList<SqlNode>, ImmutableList<SqlNode>> pair = getGroupExprs(); final AggChecker aggChecker = new AggChecker(validator, this, pair.left, pair.right, distinct); if (deep) { expr.accept(aggChecker); } // Return whether expression exactly matches one of the group // expressions. return aggChecker.isGroupExpr(expr); }
if (isAggregate(select)) { aggScope = new AggregatingSelectScope(selectScope, select, false); selectScopes.put(select, aggScope); } else { new AggregatingSelectScope(selectScope, select, true);
public void validateExpr(SqlNode expr) { checkAggregateExpr(expr, true); }
public boolean checkAggregateExpr(SqlNode expr, boolean deep) { // Fully-qualify any identifiers in expr. if (deep) { expr = validator.expand(expr, this); } // Make sure expression is valid, throws if not. Pair<ImmutableList<SqlNode>, ImmutableList<SqlNode>> pair = getGroupExprs(); final AggChecker aggChecker = new AggChecker(validator, this, pair.left, pair.right, distinct); if (deep) { expr.accept(aggChecker); } // Return whether expression exactly matches one of the group // expressions. return aggChecker.isGroupExpr(expr); }
public SelectScope getRawSelectScope(SqlSelect select) { SqlValidatorScope scope = getSelectScope(select); if (scope instanceof AggregatingSelectScope) { scope = ((AggregatingSelectScope) scope).getParent(); } return (SelectScope) scope; }
if (isAggregate(select)) { aggScope = new AggregatingSelectScope(selectScope, select, false); selectScopes.put(select, aggScope); } else { new AggregatingSelectScope(selectScope, select, true);
public SqlValidatorScope getOperandScope(SqlCall call) { if (call.getOperator().isAggregator()) { // If we're the 'SUM' node in 'select a + sum(b + c) from t // group by a', then we should validate our arguments in // the non-aggregating scope, where 'b' and 'c' are valid // column references. return parent; } else { // Check whether expression is constant within the group. // // If not, throws. Example, 'empno' in // SELECT empno FROM emp GROUP BY deptno // // If it perfectly matches an expression in the GROUP BY // clause, we validate its arguments in the non-aggregating // scope. Example, 'empno + 1' in // // SELECT empno + 1 FROM emp GROUP BY empno + 1 final boolean matches = checkAggregateExpr(call, false); if (matches) { return parent; } } return super.getOperandScope(call); }
public SelectScope getRawSelectScope(SqlSelect select) { SqlValidatorScope scope = getSelectScope(select); if (scope instanceof AggregatingSelectScope) { scope = ((AggregatingSelectScope) scope).getParent(); } return (SelectScope) scope; }
public SqlValidatorScope getOperandScope(SqlCall call) { if (call.getOperator().isAggregator()) { // If we're the 'SUM' node in 'select a + sum(b + c) from t // group by a', then we should validate our arguments in // the non-aggregating scope, where 'b' and 'c' are valid // column references. return parent; } else { // Check whether expression is constant within the group. // // If not, throws. Example, 'empno' in // SELECT empno FROM emp GROUP BY deptno // // If it perfectly matches an expression in the GROUP BY // clause, we validate its arguments in the non-aggregating // scope. Example, 'empno + 1' in // // SELECT empno + 1 FROM emp GROUP BY empno + 1 final boolean matches = checkAggregateExpr(call, false); if (matches) { return parent; } } return super.getOperandScope(call); }