Grouping extends CompositeOperator<Grouping> { public Grouping withResultProjection(final EvaluationExpression resultProjection) { this.setResultProjection(resultProjection); return this; }  @Override void addImplementation(final SopremoModule module); @Override void appendAsString(final Appendable appendable); @Override boolean equals(final Object obj); EvaluationExpression getDefaultGroupingKey(); EvaluationExpression getGroupingKey(final int index); EvaluationExpression getGroupingKey(final JsonStream input); @SuppressWarnings("unchecked") List<OrderingExpression> getInnerGroupOrder(final int inputIndex); EvaluationExpression getResultProjection(); @Override int hashCode(); @Property(hidden = true) void setDefaultGroupingKey(final EvaluationExpression defaultGroupingKey); @Property(preferred = true, input = true) @Name(preposition = "by") void setGroupingKey(final int inputIndex, final EvaluationExpression keyExpression); void setGroupingKey(final JsonStream input, final EvaluationExpression keyExpression); void setInnerGroupOrder(final int inputIndex, final List<OrderingExpression> innerGroupOrder); void setInnerGroupOrder(final int inputIndex, final OrderingExpression... innerGroupOrder); @Property(preferred = true) @Name(preposition = "into") void setResultProjection(final EvaluationExpression resultProjection); Grouping withGroupingKey(final EvaluationExpression groupingKey); Grouping withGroupingKey(final int inputIndex, final EvaluationExpression groupingKey); Grouping withInnerGroupOrdering(final int index, final List<OrderingExpression> innerGroupOrder); Grouping withInnerGroupOrdering(final int index, final OrderingExpression... innerGroupOrder); Grouping withResultProjection(final EvaluationExpression resultProjection);  }
@Test public void shouldPerformSimpleGroupBy() { final SopremoTestPlan sopremoPlan = new SopremoTestPlan(1, 1); final Grouping aggregation = new Grouping().withResultProjection( createFunctionCall(CoreFunctions.COUNT, new InputSelection(0))); aggregation.setInputs(sopremoPlan.getInputOperator(0)); sopremoPlan.getOutputOperator(0).setInputs(aggregation); sopremoPlan.getInput(0). addObject("id", 1, "dept", 1, "income", 12000). addObject("id", 2, "dept", 1, "income", 13000). addObject("id", 3, "dept", 2, "income", 15000). addObject("id", 4, "dept", 1, "income", 10000). addObject("id", 5, "dept", 3, "income", 8000). addObject("id", 6, "dept", 2, "income", 5000). addObject("id", 7, "dept", 1, "income", 24000); sopremoPlan.getExpectedOutput(0). addValue(7); sopremoPlan.trace(); sopremoPlan.run(); }