confluentinc/ksql

Support FIND_FIRST Lambda Function

Open

#7,387 建立於 2021年4月15日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Java (5,739 star) (1,048 fork)batch import
enhancementgood first issuestreaming-engine

描述

Is your feature request related to a problem? Please describe.

A user requested the ability to map an array into fields where the arrays have some predefined set of values:

Sample Data: 
 - FOO: [{"key":"a", "val":2}, {"key":"b", "val":4}]
 - FOO: [{"key":"b", "val":3}]
 
Sample Output:

| a | b |
|---|---|
| 2 | 4 |
|nul| 3 |

Describe the solution you'd like

We could implement FIND_FIRST(array, x -> predicate(x)) lambda function and implement this as:

SELECT FIND_FIRST(FOO, x -> x = 'a') AS a, FIND_FIRST(FOO, x -> x = 'b') AS b FROM source;

Describe alternatives you've considered

Implement PIVOT - this is a little bit more involved and this is a good general use case for lambdas.

貢獻者指南