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 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); }