laertis90 opened a new issue, #12685:
URL: https://github.com/apache/druid/issues/12685

   Please provide a detailed title (e.g. "Broker crashes when using TopN query 
with Bound filter" instead of just "Broker crashes").
   
   ### Affected Version
   
   0.22.1
   
   ### Description
   
   I have a datasource that I'm trying to query using quantiles to get the 
median value (P50).
   When there is odd number of values (eg. `10, 20, 30, 40, 50`) I get the mean 
value correctly: `30`.
   When there is even number of values (eg. `10, 20, 30, 40`) the mean value 
would normally be `25`, but I'm getting `30` instead.
   
   Sample json query:
   
   ```
   {
     "dataSource": "datasource_name",
     "dimensions": [
       {
         "dimension": "__time",
         "outputName": "date",
         "outputType": "LONG",
         "type": "default"
       },
       {
         "dimension": "dimension1",
         "outputName": "dimension1",
         "outputType": "STRING",
         "type": "default"
       },
       {
         "dimension": "dimension2",
         "outputName": "dimension2",
         "outputType": "STRING",
         "type": "default"
       }
     ],
     "granularity": {
       "type": "all"
     },
     "filter": {
       "fields": [
         {
           "dimension": "dimension1",
           "values": [
             "dimension1_filter"
           ],
           "type": "in"
         },
         {
           "dimension": "dimension2",
           "values": [
             "dimension2_filter"
           ],
           "type": "in"
         }
       ],
       "type": "and"
     },
     "aggregations": [
       {
         "name": "quantile_quantity",
         "fieldName": "quantity",
         "type": "quantilesDoublesSketch",
       }
     ],
     "postAggregations": [
       {
         "name": "aggregated_quantity",
         "field": {
           "name": "aggregated_quantity",
           "fieldName": "quantile_quantity",
           "type": "fieldAccess"
         },
         "fraction": 0.5,
         "type": "quantilesDoublesSketchToQuantile",
       }
     ],
     "intervals": [
       "2022-06-05/2022-06-12"
     ],
     "queryType": "groupBy"
   }
   ```
   
   Above query has some filters on dimensions just to limit the result to a 
sample of 4 values and reproduce this issue. I'm including the whole query 
above just in case any of these configurations affect the result I'm getting.
   
   This is the result:
   
   ```
   dimension1    aggregated_quantity    dimension2    quantile_quantity    date
   dimension1_filter    30    dimension2_filter    4    1654387200000
   ```
   
   Is there some configuration I'm missing to calculate the correct median 
value?
   
   Thank you!


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

To unsubscribe, e-mail: [email protected]

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