mr0al opened a new issue #8746: Group by on a multi value dimension with 
aggregations Druid 0.16.0
URL: https://github.com/apache/incubator-druid/issues/8746
 
 
   I've got the following use case. I want to group by a multi-value dimension 
and then aggregate on different column depending on the value of the 
"multi-value-dimension".. i.e I would like to aggregate sum on d3 if value = d1 
or d4 if value =d2
   
   ```
   
   multi-value-dimension | d1 | d2 | d3 | d4
   -- | -- | -- | -- | --
   [a,b] | a | b | 1 | 2
   [c,a] | c | a | 1 | 2
   
   multi-value-dimension |   |   |   |  
   a | a | b | 1 | 2
   b | a | b | 1 | 2
   c | c | a | 1 | 2
   a | c | a | 1 | 2
   
   Aggregation |   |   |   |  
   multi-value-dimension | sum aggregation on d3 or d4 |   |   |  
   a | 3(1+2) |   |   |  
   b | 2 |   |   |  
   c | 1 |   |   |  
   
   
   ```
   
   Currently, if I try and reference the MVD as per below my aggregation comes 
back with 0
   
   {"queryType":"groupBy","dataSource":{"type":"table","name":"datasource"},
   
"intervals":{"type":"intervals","intervals":["-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z"]},
   "filter":null,"granularity":{"type":"all"},
   "dimensions":[
   
{"type":"default","dimension":"MVD","outputName":"MVD","outputType":"STRING"}]
   "aggregations":[{"type":"doubleSum","name":"a0","fieldName":null,
   "expression":"if(MVD == d1,d3,d4)"}],
   "postAggregations":[],"having":null,"limitSpec":{"type":"NoopLimitSpec"},
   
"context":{"sqlQueryId":"964a93cd-8c47-45b2-ad70-806536cf21ea"},"descending":false}
   
   
   For the above example this will return 
   a | 0
   b | 0
   c | 0
   
   which doesn't quite make sense..
   
   
   
   One way to achieve this would be a nested group by first retrieving all 
multi-value dimensions and then groupby again on them but would like to avoid 
that if possible.
   
   

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

Reply via email to