confluentinc/ksql

Support FIND_FIRST Lambda Function

Open

#7 387 ouverte le 15 avr. 2021

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)Java (1 048 forks)batch import
enhancementgood first issuestreaming-engine

Métriques du dépôt

Stars
 (5 739 stars)
Métriques de merge PR
 (Merge moyen 4j 20h) (6 PRs mergées en 30 j)

Description

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.

Guide contributeur