Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
TEIID-3263 fixing aggregate processing
  • Loading branch information
shawkins committed Dec 17, 2014
1 parent 8b16727 commit eb24239
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -534,9 +534,9 @@ private TupleBatch groupSortOutputPhase() throws FunctionExecutionException, Exp
for (int i = 0; i < size; i++) {
vals.set(i, tuple.get(i));
}
int index = size;
for (int i = 0; i < this.groupSortfunctions.length; i++) {
AggregateFunction aggregateFunction = this.groupSortfunctions[i];
int index = size;
aggregateFunction.setState(tuple, index);
index+=this.accumulatorStateCount[i];
vals.set(size + i, aggregateFunction.getResult(getContext()));
Expand Down
Expand Up @@ -509,6 +509,24 @@ private void sampleDataBQT_defect9842(FakeDataManager dataMgr) throws Exception
helpProcess(plan, dataManager, expected);
}

@Test public void testGroupSortMultipleAggregates() throws Exception {
String sql = "select e1, min(e2), max(e3) from pm1.g1 group by e1";

List[] expected = new List[] {
Arrays.asList(null, 1, false),
Arrays.asList("a", 0, true),
Arrays.asList("b", 2, false),
Arrays.asList("c", 1, true),
};

// Construct data manager with data
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);

ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
helpProcess(plan, dataManager, expected);
}

public static class SumAll implements UserDefinedAggregate<Integer> {

private boolean isNull = true;
Expand Down

0 comments on commit eb24239

Please sign in to comment.