@Override public void visit(Function function) { boolean recognized = isRecognized(function); if (!recognized) { // try to extract SUM // parameters for COUNT are ignored, as explained in super final String fnName = function.getName(); if (fnName.equalsIgnoreCase("SUM")) { recognized = isRecognized(function.getParameters()); if (recognized) { final ValueExpression expr = popFromExprStack(); createSum(expr, function.isDistinct()); } } else if (fnName.equalsIgnoreCase("COUNT")) { final List<ValueExpression> expressions = new ArrayList<ValueExpression>(); if (function.isDistinct()) { // putting something on stack only if isDistinct is set to // true recognized = isRecognized(function.getParameters()); // it might happen that we put on stack something we don't // use // this is the case only when some exprs are recognized and // the others not if (recognized) { // create a list of expressions int numParams = 0; final ExpressionList params = function.getParameters(); if (params != null) numParams = params.getExpressions().size(); for (int i = 0; i < numParams; i++) expressions.add(popFromExprStack()); } } else recognized = true; if (recognized) // finally, create CountAgg out of expressions (empty if // nonDistinct) createCount(expressions, function.isDistinct()); } } if (!recognized) // normal call to parent super.visit(function); }
@Override public void visit(Addition adtn) { if (!isRecognized(adtn)) // normal call to parent super.visit(adtn); }
@Override public void visit(Subtraction s) { if (!isRecognized(s)) // normal call to parent super.visit(s); }
@Override public void visit(Parenthesis prnths) { if (!isRecognized(prnths)) // normal call to parent super.visit(prnths); }
@Override public void visit(Multiplication m) { if (!isRecognized(m)) // normal call to parent super.visit(m); }
@Override public void visit(Division dvsn) { if (!isRecognized(dvsn)) // normal call to parent super.visit(dvsn); }