Aggregate function for compressed big decimal in Druid

39 views Asked by At

I have a column in Druid database with the type of Compressed Big Decimal. I can not use any aggregate functions like sum or even other functions like ABS on this columns.

When I try to use Aggregate functions like Sum like below

Select Sum(my_column) from my_table

it gives me the following errors.

Cannot apply 'SUM' to arguments of type 'SUM(<COMPLEX>)'. Supported form(s): 'SUM()'

1

There are 1 answers

1
Amir Abolhasani On

Unfortunately, Druid does not support aggregate functions on COMPRESSED BIG DECIMAL. I had to use API query instead of Native SQL like:

{
  "queryType": "timeseries",
  "dataSource": "mytable",
  "intervals": [ "2022-01-01T00:00:00.000/2024-01-01T00:00:00.000" ],
  "granularity": "all",
  "aggregations": [
    { "type": "compressedBigDecimalSum", "name": "mycolumn", "mycolumn": "adItemPrice" }
  ],
  "filter": {
    "type": "selector",
    "dimension": "myOtherColumn",
    "value": "myValue"
  },
  "context": {
    "grandTotal": true
  }
}