himanshug 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_r306059186
##########
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:
renamed variable names to align them better with the comment, it should be
easier to follow now.
I thought of breaking the method and then realized most of it is actually
method calls which are big because of the number of arguments they take. take a
look now, if it still looks difficult then I can try to break it.
----------------------------------------------------------------
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]