druid icon indicating copy to clipboard operation
druid copied to clipboard

Aggregation on strings(dimension)

Open linbojin opened this issue 10 years ago • 12 comments

A recent discussion on this topic can be found here: https://groups.google.com/forum/#!topic/druid-user/lZVvnaLjkEA

I have data schema as follow, dimensions are [mac, username, osType] and metric is traffic:

  clientMac          username        osType      traffic
00:19:F8:10:00:01      user0          Window         10
00:19:F8:10:00:01      user1          Linux          20
00:19:F8:10:00:02      user2         Android         30
00:19:F8:10:00:03      user3           ios           40

And what I want to do is to group the traffics(return sum), username(return array), osType(return array) by clientMac looks like:

[
  {
    "version": "v1",
    "timestamp": "2015-11-01T00:00:00.000Z",
    "event": {
      "clientMac": "00:19:F8:10:00:01",
      "totalCount": 2,
      "username": ["user0", "user1"],
      "osType": ["Window", "Linux"],
      "traffic": 30
    }
  },
  {
    "version": "v1",
    "timestamp": "2015-11-01T00:00:00.000Z",
    "event": {
      "clientMac": "00:19:F8:10:00:02",
      "totalCount": 1,      
       "username": ["user2"],
      "osType": ["Android"],
      "traffic": 30
    }
  },
  {
    "version": "v1",
    "timestamp": "2015-11-01T00:00:00.000Z",
    "event": {
      "clientMac": "00:19:F8:10:00:03",
      "totalCount": 1,              
      "username": ["user3"],
      "osType": ["ios"],
      "traffic": 40
    }
  }
]

linbojin avatar Jan 21 '16 07:01 linbojin

:+1: we are stuck with this too, would be cool to have a first() aggregator or something, so we can select string fields

almike avatar Feb 17 '16 10:02 almike

A topN set aggregator would be nice too, even lacking counts, to get a representative set of high cardinality dimensions.

blakelivingston avatar Apr 15 '16 21:04 blakelivingston

Inside Spark this is a function named collect_list can do such stuff: https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/functions.scala#L201-L225 screen shot 2016-06-02 at 16 43 07

linbojin avatar Jun 02 '16 09:06 linbojin

hi, are you fix this problem?

wzy1213 avatar Feb 19 '19 05:02 wzy1213

Any update on this feature? Is there any way we can achieve string aggregation in the latest version of Druid ?

vikramarsid avatar Aug 12 '19 17:08 vikramarsid

Hi, Any update on this issue? Is this feature going to be available in new version of Druid?

Thanks! Manu

manu6909 avatar Dec 05 '19 12:12 manu6909

Sadly this won't be in 0.17

jnaous avatar Dec 05 '19 13:12 jnaous

Ok. Thanks @jnaous . Is it possible to use lookups as a workaround? Like, use lookups for string columns on aggregation has to be executed with a numeric value as key and actual string as value. Then if an aggregation is executed on that column, will it be executed on the numeric key and the result will be replaced with the actual string?

manu6909 avatar Dec 05 '19 13:12 manu6909

Interesting :) I'm not sure. You'd have to try it!

jnaous avatar Dec 05 '19 13:12 jnaous

Cool. Thanks! I will give it a try

manu6909 avatar Dec 05 '19 13:12 manu6909

This issue has been marked as stale due to 280 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

stale[bot] avatar Sep 11 '20 03:09 stale[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

stale[bot] avatar Oct 11 '20 23:10 stale[bot]