confluentinc/ksql

Convert a MAP to ARRAY with ENTRIES()

Open

#5,452 创建于 2020年5月21日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Java (1,048 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (5,739 star)
PR 合并指标
 (平均合并 4天 20小时) (30 天内合并 6 个 PR)

描述

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?

贡献者指南