Druid: Implement 'last' and 'first' aggregator

Created on 16 Apr 2016  Â·  7Comments  Â·  Source: apache/druid

Similar to max/min aggregators, it would be useful to implement a first/last aggregator which could be specified at index-time thereby only indexing the first or last row sent to Druid.

Currently, the only way to achieve this is to store every row in Druid and use a select query to get the first or last row ordered by timestamp.

Feature Starter

Most helpful comment

This would be great. I would advocate making the aggregates 'firstBy' and 'lastBy' so that you could do: FIRST_BY(revenue,__time) to get first by time or FIRST_BY(revenue,my_id) to get it by my_id there should also be a way to define the compare on my_id (lexiographic, alphanumeric) and maybe some other comparison options like how much space to allocate for string comparisons.

Related to: https://github.com/druid-io/druid/issues/2989

Also to add some color for use cases:

https://groups.google.com/forum/#!topic/druid-user/nCghqQBhUC8

https://groups.google.com/forum/#!topic/imply-user-group/rhsQRC5v5G8

All 7 comments

This would be great. I would advocate making the aggregates 'firstBy' and 'lastBy' so that you could do: FIRST_BY(revenue,__time) to get first by time or FIRST_BY(revenue,my_id) to get it by my_id there should also be a way to define the compare on my_id (lexiographic, alphanumeric) and maybe some other comparison options like how much space to allocate for string comparisons.

Related to: https://github.com/druid-io/druid/issues/2989

Also to add some color for use cases:

https://groups.google.com/forum/#!topic/druid-user/nCghqQBhUC8

https://groups.google.com/forum/#!topic/imply-user-group/rhsQRC5v5G8

Tagged as Easy assuming we are just doing "by time" at first.

@gianm what if the user has to provide explicit amount of bytes to use for comparison?

It looks like nobody has asked for by-anything-other-than time yet, and doing by-time is simpler…

a good start for sure.

This would also probably end up being "firsty" and "lasty" in that if there are multiple events with the same max timestamp, one of them will be picked arbitrarily as the "last" one.

+1

Here's my use case: https://groups.google.com/forum/#!topic/druid-user/5ld1gAq6D_g

I think for my case time would also be adequate.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akashdw picture akashdw  Â·  5Comments

cesure picture cesure  Â·  5Comments

sascha-coenen picture sascha-coenen  Â·  5Comments

AndyLin0128 picture AndyLin0128  Â·  4Comments

MaxOrelus picture MaxOrelus  Â·  3Comments