abhishekagarwal87 opened a new pull request #10653:
URL: https://github.com/apache/druid/pull/10653


   ### Description
   
   Post-aggregators, when used with subtotals, errors if the post-aggregator 
depends on a dimension that is absent in one of the subtotal. An example query 
is as follows
   
   ```
   SELECT dim2, SUM(cnt), GROUPING(dim2), 
   CASE WHEN GROUPING(dim2) = 1 THEN 'ALL' ELSE dim2 END
   FROM druid.foo
   GROUP BY GROUPING SETS ( (dim2), () )
   ```
   
   The exception is 
   ```
   java.lang.IllegalArgumentException: Missing fields [[d0]] for postAggregator 
[p0]
   
        at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
        at org.apache.druid.query.Queries.prepareAggregations(Queries.java:118)
        at 
org.apache.druid.query.groupby.GroupByQuery.<init>(GroupByQuery.java:210)
        at 
org.apache.druid.query.groupby.GroupByQuery.<init>(GroupByQuery.java:88)
        at 
org.apache.druid.query.groupby.GroupByQuery$Builder.build(GroupByQuery.java:1175)
        at 
org.apache.druid.query.groupby.GroupByQuery.withDimensionSpecs(GroupByQuery.java:804)
        at 
org.apache.druid.query.groupby.strategy.GroupByStrategyV2.processSubtotalsSpec(GroupByStrategyV2.java:446)
        at 
org.apache.druid.query.groupby.GroupByQueryQueryToolChest.mergeGroupByResultsWithoutPushDown(GroupByQueryQueryToolChest.java:250)
        at 
org.apache.druid.query.groupby.GroupByQueryQueryToolChest.mergeGroupByResults(GroupByQueryQueryToolChest.java:177)
        at 
org.apache.druid.query.groupby.GroupByQueryQueryToolChest.initAndMergeGroupByResults(GroupByQueryQueryToolChest.java:149)
        at 
org.apache.druid.query.groupby.GroupByQueryQueryToolChest.lambda$mergeResults$0(GroupByQueryQueryToolChest.java:122)
        at 
org.apache.druid.query.FinalizeResultsQueryRunner.run(FinalizeResultsQueryRunner.java:110)
   ```
   
   I have removed the dimension renaming. We only carry over the dimensions 
included in the subtotal spec while generating results for any subtotal. 
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] been tested in a test Druid cluster.
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `GroupyByStrategyV2`
   


----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to