gianm commented on a change in pull request #8109: fix merging of groupBy
subtotal spec results
URL: https://github.com/apache/incubator-druid/pull/8109#discussion_r305605416
##########
File path:
processing/src/main/java/org/apache/druid/query/groupby/strategy/GroupByStrategyV2.java
##########
@@ -419,36 +436,81 @@ public Row apply(final Row row)
false
)
);
+
+
List<Sequence<Row>> subtotalsResults = new ArrayList<>(subtotals.size());
Map<String, DimensionSpec> queryDimensionSpecs = new
HashMap(queryWithoutSubtotalsSpec.getDimensions().size());
+ List<String> queryDimNames = new
ArrayList(queryWithoutSubtotalsSpec.getDimensions().size());
+
for (DimensionSpec dimSpec : queryWithoutSubtotalsSpec.getDimensions()) {
queryDimensionSpecs.put(dimSpec.getOutputName(), dimSpec);
+ queryDimNames.add(dimSpec.getOutputName());
}
for (List<String> subtotalSpec : subtotals) {
GroupByQuery subtotalQuery =
queryWithoutSubtotalsSpec.withDimensionSpecs(
subtotalSpec.stream()
- .map(s -> new DefaultDimensionSpec(s, s,
queryDimensionSpecs.get(s).getOutputType()))
+ .map(queryDimensionSpecs::get)
.collect(Collectors.toList())
);
- subtotalsResults.add(applyPostProcessing(
- mergeResults(new QueryRunner<Row>()
- {
- @Override
- public Sequence<Row> run(QueryPlus<Row> queryPlus, Map<String,
Object> responseContext)
+ if (Utils.isPrefix(subtotalSpec, queryDimNames)) {
+ subtotalsResults.add(applyPostProcessing(
+ mergeResults(new QueryRunner<Row>()
{
- return GroupByRowProcessor.getRowsFromGrouper(
- queryWithoutSubtotalsSpec,
- subtotalSpec,
- grouperSupplier
- );
- }
- }, subtotalQuery, null),
- subtotalQuery
- )
- );
+ @Override
+ public Sequence<Row> run(QueryPlus<Row> queryPlus, Map<String,
Object> responseContext)
+ {
+ return GroupByRowProcessor.getRowsFromGrouper(
+ queryWithoutSubtotalsSpec,
+ subtotalSpec,
+ grouperSupplier
Review comment:
Or maybe breaking the method up would make it easier.
I guess what I'm trying to say is when reading, I was wishing it was more
clear when we were using `Grouper#1`, when `Grouper#2`, and also who's
responsible for closing what.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]