pinot icon indicating copy to clipboard operation
pinot copied to clipboard

Support Array function for multi-value columns

Open xiangfu0 opened this issue 5 years ago • 5 comments
trafficstars

Inspired by presto array functions(https://prestodb.io/docs/current/functions/array.html), we can first support those transform functions on multi-value to 1 value result.

  • [x] array_average
  • [x] array_max
  • [x] array_min
  • [x] array_sum
  • [ ] array_position
  • [ ] cardinality
  • [ ] contains
  • [ ] element_at

xiangfu0 avatar Sep 30 '20 19:09 xiangfu0

cc: @npawar @KKcorps

xiangfu0 avatar Oct 01 '20 06:10 xiangfu0

Optimize query perf by existing multi-value aggregation functions capability. https://github.com/apache/incubator-pinot/pull/6127

xiangfu0 avatar Oct 09 '20 21:10 xiangfu0

@xiangfu0 Are there plans to implement the remaining functions, in particular, element_at ?

Currently, we need to use arraySlice for picking a single element from an array.

jpohanka avatar Jul 25 '22 15:07 jpohanka

do we want to support any boolean functions like

  • [ ] MATCH_ANY
  • [ ] MATCH_ALL
  • [ ] MATCH_NONE (all of these are element-wise predicate evaluators)

walterddr avatar Aug 09 '22 20:08 walterddr

Is there any plan to support ARRAY_AGG or ARRAY_JOIN aggregation function, which concatenates the values into an array?

skjindal93 avatar Sep 16 '22 14:09 skjindal93

Do we have support on element_at already? Is this for returning the item at specific index?

monicaluodialpad avatar Jun 05 '23 18:06 monicaluodialpad

We have arrayElementAt for primitive types https://github.com/apache/pinot/blob/master/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArrayFunctions.java#L156

npawar avatar Jun 06 '23 15:06 npawar

@npawar Hi, thank you! I also find this but it seems that we don't have query support: https://github.com/apache/pinot/blob/master/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java I didn't find any related function types.

monicaluodialpad avatar Jun 07 '23 00:06 monicaluodialpad

@npawar Hi, thank you! I also find this but it seems that we don't have query support: https://github.com/apache/pinot/blob/master/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java I didn't find any related function types.

In the link I shared, they've been added as ScalarFunctions. Scalar functions work for ingestion as well as query, so you should be able to use them in query. Are you not able to get them to work at query time?

npawar avatar Jun 07 '23 02:06 npawar