https://pinot.apache.org/ logo
d

Damiano

05/11/2020, 10:21 AM
Hello everybody, is there a way to create an aggregator and return more than one column as result? I have many aggregators to implements and most of them have similar implementations so i thought to share their logic inside ONE aggregator, something like: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
k

Kishore G

05/11/2020, 4:37 PM
Yes. Its similar to what you did for other aggregation function
d

Damiano

05/11/2020, 5:20 PM
@Kishore G no wait i missed that part, i know that ONE aggregator can only returns one value only, no?
I mean creating one aggregator like "stats" can i return min, max, avg etc values? instead of using min(amount), max(amount), avg(amount) and so on...
k

Kishore G

05/11/2020, 5:24 PM
you can return whatever you want from the extractFinalResult
we call toString on that
so you can return a {json}
d

Damiano

05/11/2020, 5:26 PM
omg really?? we were talking about serializing a list etc..do you remember? i did not think it was so simple
that's sounds PERFECT because i will avoid sorting the block again and again (for each aggregator)
@Kishore G if i return a json what about the name of the columns?
can i call they something like avg_column max_column min_column
something like that?
k

Kishore G

05/11/2020, 5:42 PM
its upto you
high level name will be stats
d

Damiano

05/11/2020, 5:45 PM
Ok, if the high level is "stats" and i return a json like {"a": 1, "b": 2} does it mean that i can reach "a" doing stats.a ?
k

Kishore G

05/11/2020, 5:46 PM
yep
pinot will just return the json
you need to parse it further
d

Damiano

05/11/2020, 5:46 PM
that's awesome, you know? 😄
k

Kishore G

05/11/2020, 5:47 PM
👍
d

Damiano

05/11/2020, 5:48 PM
thats another good info to put on doc, i will do it as i told you 👍