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


   ### Description
   
   Running queries with distinct aggregations on different fields require us to 
enable a calcite rule AggregateExpandDistinctAggregatesRule.INSTANCE which is 
currently not enabled. Instead `AggregateExpandDistinctAggregatesRule.JOIN rule 
is used which plans queries with multiple distinct aggregations as a Join query 
with a join condition of type `IS_NOT_DISTINCT_FROM`  but druid only supports 
joins with equality conditions. AggregateExpandDistinctAggregatesRule.INSTANCE 
rule, on the other hand, uses subtotal specs, to run the queries with distinct 
aggregations. This rule also requires the grouping aggregator which has been 
added very recently. 
   
   With AggregateExpandDistinctAggregatesRule.INSTANCE, query planning 
completes just fine however, after planning, the query execution fails. This is 
due to a bug in how druid procures merge buffers. Druid undercounts required 
merge buffers when there is a nested query and subquery has subtotals.
   
   This patch fixes the logic to compute required merge buffers. Additionally, 
a flag has been added to control to switch between old and new behavior. 
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is 
a corresponding issue (referenced above), it's not necessary to repeat the 
description here, however, you may choose to keep one summary sentence. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the 
problem? -->
   
   
   
   This PR has:
   - [ ] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] 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.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to