confluentinc/ksql

Convert a MAP to ARRAY with ENTRIES()

Open

#5.452 geöffnet am 21. Mai 2020

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (1.048 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (5.739 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 4T 20h) (6 gemergte PRs in 30 T)

Beschreibung

I have data in the style of {"a":1, "b":{"b1": {"c":"aaa", "d":"bbb"}, "b2": {"c":"ccc", "d":"ddd"}}}

With schema defined as

a INT,
b MAP<STRING, STRUCT<
  c STRING,
  d STRING
>>

I would like to convert it to

a INT,
b ARRAY<STRUCT<
  c STRING,
  d STRING
>>

To look like this {"a":1, "b":[{"c":"aaa", "d":"bbb"},{"c":"ccc", "d":"ddd"}]}

Currently using ENTRIES() returns

Function 'ENTRIES' does not accept parameters (MAP<STRING, STRUCT<C STRING, D STRING>>).
Valid alternatives are:
ENTRIES(MAP<STRING, DOUBLE> map, BOOLEAN sorted)
ENTRIES(MAP<STRING, BOOLEAN> map, BOOLEAN sorted)
ENTRIES(MAP<STRING, VARCHAR> map, BOOLEAN sorted)
ENTRIES(MAP<STRING, BIGINT> map, BOOLEAN sorted)
ENTRIES(MAP<STRING, INT> map, BOOLEAN sorted)

Could ENTRIES() be extended to support this scenario?

Contributor Guide