clintropolis commented on code in PR #15232:
URL: https://github.com/apache/druid/pull/15232#discussion_r1369335570
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupingEngine.java:
##########
@@ -788,11 +788,11 @@ private static boolean
summaryRowPreconditions(GroupByQuery query)
private static Iterator<ResultRow> summaryRowIterator(GroupByQuery q)
{
List<AggregatorFactory> aggSpec = q.getAggregatorSpecs();
- Object[] values = new Object[aggSpec.size()];
+ ResultRow resultRow =
ResultRow.create(q.getResultRowSizeWithPostAggregators());
for (int i = 0; i < aggSpec.size(); i++) {
- values[i] = aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get();
+ resultRow.set(i, aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get());
}
Review Comment:
oh, I think you need to actually compute the postaggs... which is why the
test is failing in default value mode, see `mergeResults` for an example,
something like
```
private static Iterator<ResultRow> summaryRowIterator(GroupByQuery q)
{
List<AggregatorFactory> aggSpec = q.getAggregatorSpecs();
ResultRow resultRow =
ResultRow.create(q.getResultRowSizeWithPostAggregators());
for (int i = 0; i < aggSpec.size(); i++) {
resultRow.set(i, aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get());
}
Map<String, Object> map = resultRow.toMap(q);
for (int i = 0; i < q.getPostAggregatorSpecs().size(); i++) {
final PostAggregator postAggregator =
q.getPostAggregatorSpecs().get(i);
final Object value = postAggregator.compute(map);
resultRow.set(q.getResultRowPostAggregatorStart() + i, value);
map.put(postAggregator.getName(), value);
}
return Collections.singleton(resultRow).iterator();
}
```
##########
processing/src/main/java/org/apache/druid/query/groupby/GroupingEngine.java:
##########
@@ -788,11 +788,11 @@ private static boolean
summaryRowPreconditions(GroupByQuery query)
private static Iterator<ResultRow> summaryRowIterator(GroupByQuery q)
{
List<AggregatorFactory> aggSpec = q.getAggregatorSpecs();
- Object[] values = new Object[aggSpec.size()];
+ ResultRow resultRow =
ResultRow.create(q.getResultRowSizeWithPostAggregators());
for (int i = 0; i < aggSpec.size(); i++) {
- values[i] = aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get();
+ resultRow.set(i, aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get());
}
Review Comment:
oh, I think you need to actually compute the postaggs... which is why the
test is failing in default value mode, see `mergeResults` for an example,
something like
```
private static Iterator<ResultRow> summaryRowIterator(GroupByQuery q)
{
List<AggregatorFactory> aggSpec = q.getAggregatorSpecs();
ResultRow resultRow =
ResultRow.create(q.getResultRowSizeWithPostAggregators());
for (int i = 0; i < aggSpec.size(); i++) {
resultRow.set(i, aggSpec.get(i).factorize(new
AllNullColumnSelectorFactory()).get());
}
Map<String, Object> map = resultRow.toMap(q);
for (int i = 0; i < q.getPostAggregatorSpecs().size(); i++) {
final PostAggregator postAggregator =
q.getPostAggregatorSpecs().get(i);
final Object value = postAggregator.compute(map);
resultRow.set(q.getResultRowPostAggregatorStart() + i, value);
map.put(postAggregator.getName(), value);
}
return Collections.singleton(resultRow).iterator();
}
```
makes the test pass in both modes for me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]