Description
Pivot an array into dynamic set of key:value properties in Analytics. This is a super powerful N1QL feature. Can that be done in Analytics, in a cleaner, better way?
N1QL syntax allows me to:
SELECT RAW OBJECT o.id:o.label for o IN
|
[
|
{"id":"test","label":"val"}
|
,
|
{"id":"test2","label":"val2"}
|
]
|
END
|
Result:
{ "test": "val", "test2": "val2" }
|
Workaround is to use encode/decode_json() functions:
select raw decode_json("{" || string_join(
|
(
|
select value encode_json(i.id) || ":" || encode_json(i.label)
|
from [
|
|
{"id":"test","label":"val"}
|
|
,
|
|
{"id":"test2","label":"val2"}
|
|
] i
|
), ","
|
) || "}")
|
Attachments
Issue Links
- duplicates
-
MB-37157 [CX] extend object_concat to support an input array
- Closed