@Test public final void testFindDistinctAggFunctions() throws PlanningException { String query = "select sum(score) + max(age) from people"; Expr expr = analyzer.parse(query); LogicalPlan plan = planner.createPlan(expr); GroupbyNode groupByNode = plan.getRootBlock().getNode(NodeType.GROUP_BY); EvalNode [] aggEvals = groupByNode.getAggFunctions(); List<AggregationFunctionCallEval> list = new ArrayList<AggregationFunctionCallEval>(); for (int i = 0; i < aggEvals.length; i++) { list.addAll(EvalTreeUtil.findDistinctAggFunction(aggEvals[i])); } assertEquals(2, list.size()); Set<String> result = Sets.newHashSet("max", "sum"); for (AggregationFunctionCallEval eval : list) { assertTrue(result.contains(eval.getName())); } }
public static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr) { AllAggFunctionFinder finder = new AllAggFunctionFinder(); expr.postOrder(finder); return finder.getAggregationFunction(); }
EvalTreeUtil { public static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr) { AllAggFunctionFinder finder = new AllAggFunctionFinder(); expr.postOrder(finder); return finder.getAggregationFunction(); } }
EvalTreeUtil { public static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr) { AllAggFunctionFinder finder = new AllAggFunctionFinder(); expr.postOrder(finder); return finder.getAggregationFunction(); }  }
EvalTreeUtil { public static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr) { AllAggFunctionFinder finder = new AllAggFunctionFinder(); expr.postOrder(finder); return finder.getAggregationFunction(); }  static void changeColumnRef(EvalNode node, String oldName, String newName); static void replace(EvalNode expr, EvalNode targetExpr, EvalNode tobeReplaced); static LinkedHashSet<Column> findUniqueColumns(EvalNode node); static List<Column> findAllColumnRefs(EvalNode node); static Schema getSchemaByTargets(Schema inputSchema, Target [] targets); static DataType getDomainByExpr(Schema inputSchema, EvalNode expr); static Collection<EvalNode> getContainExpr(EvalNode expr, Column target); static Map<EvalType, Integer> getExprCounters(EvalNode expr); static boolean containColumnRef(EvalNode expr, Column target); static boolean isJoinQual(EvalNode expr); static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr); static Collection<T> findEvalsByType(EvalNode evalNode, EvalType type); }
EvalTreeUtil { public static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr) { AllAggFunctionFinder finder = new AllAggFunctionFinder(); expr.postOrder(finder); return finder.getAggregationFunction(); }  static void changeColumnRef(EvalNode node, String oldName, String newName); static void replace(EvalNode expr, EvalNode targetExpr, EvalNode tobeReplaced); static LinkedHashSet<Column> findUniqueColumns(EvalNode node); static List<Column> findAllColumnRefs(EvalNode node); static Schema getSchemaByTargets(Schema inputSchema, Target [] targets); static DataType getDomainByExpr(Schema inputSchema, EvalNode expr); static Collection<EvalNode> getContainExpr(EvalNode expr, Column target); static Map<EvalType, Integer> getExprCounters(EvalNode expr); static boolean containColumnRef(EvalNode expr, Column target); static boolean isJoinQual(EvalNode expr); static Set<AggregationFunctionCallEval> findDistinctAggFunction(EvalNode expr); static Collection<T> findEvalsByType(EvalNode evalNode, EvalType type);  }