【发布时间】:2022-01-18 16:10:24
【问题描述】:
我正在尝试为其中一列包含的表格建模:
[{"code": "SEEYOUSOON100", "amount": "250.00", "type": "percentage"}]
[bigquery documentation] 网站的任何解决方案都返回 null。
【问题讨论】:
标签: json google-bigquery text-extraction
我正在尝试为其中一列包含的表格建模:
[{"code": "SEEYOUSOON100", "amount": "250.00", "type": "percentage"}]
[bigquery documentation] 网站的任何解决方案都返回 null。
【问题讨论】:
标签: json google-bigquery text-extraction
考虑以下方法
select
json_extract_scalar(json, '$.code') as code,
json_extract_scalar(json, '$.amount') as amount,
json_extract_scalar(json, '$.type') as type
from your_table,
unnest(json_extract_array(col)) json
如果应用于您问题中的样本数据 - 输出是
您可以使用下面的 cte 玩/测试上面的内容
with your_table as (
select '[{"code": "SEEYOUSOON100", "amount": "250.00", "type": "percentage"}]' col
)
select
json_extract_scalar(json, '$.code') as code,
json_extract_scalar(json, '$.amount') as amount,
json_extract_scalar(json, '$.type') as type
from your_table,
unnest(json_extract_array(col)) json
【讨论】: