【发布时间】:2015-07-23 14:46:24
【问题描述】:
我有一个如下所示的 Redshift 表:
id | metadata
---------------------------------------------------------------------------
1 | [{"pet":"dog"},{"country":"uk"}]
2 | [{"pet":"cat"}]
3 | []
4 | [{"country":"germany"},{"education":"masters"},{"country":"belgium"}]
- 所有数组元素只有一个字段。
- 无法保证特定字段会出现在数组的任何元素中。
- 字段名可以在数组中重复
- 数组元素可以是任意顺序
我想取回一个如下所示的表格:
id | field | value
------------------------
1 | pet | dog
1 | country | uk
2 | pet | cat
4 | country | germany
4 | education | masters
4 | country | belgium
然后我可以将它与我对输入表其余部分的查询结合起来。
我尝试过使用 Redshift JSON 函数,但无法在 Redshift 中编写函数/使用循环/拥有变量,我真的看不到这样做的方法!
如果我能澄清其他任何事情,请告诉我。
【问题讨论】:
标签: json amazon-redshift