Query for performing Max (String)

Hello Druid Gurus,

Does Druid have the capability to apply MAX on a string column?

Basically I am writing a Druid query to return the max of a flag (Y/N). Along with that, i also want to agrgegate a metric (across all dimensions).

I checked the group and there was a note on TopN last year. This worked, but the metric (usd_amount) value returned is only for the top flag. Below is some sample data and expected results.

Sample Data

Premium_Customer Amount

Y 100

N 300

The expected result is

Y 400

Is this possible ?



Hey Kasi,

You could do this with two queries: one topN to get the premium_customer flags and one timeseries to get the sum of amount.

Or you could do it with one timeseries query that uses a sum aggregator for the amount, and a javascript aggregator (see http://druid.io/docs/latest/querying/aggregations.html) to get the correct flag. Javascript aggregators can read dimensions, so that part will work fine, but they do have to return numbers, so you could have the aggregator return 1 or 0 rather than ā€˜Yā€™ or ā€˜Nā€™.