【发布时间】:2019-07-20 02:23:42
【问题描述】:
我在 bigquery 中有一个表,其中有对象,并且对于每个对象,我都有一些字符串化的 json。在 json 中,示例行如下所示:
{
"ObjectID": "1984931229",
"indexed_abstract": "{\"IndexLength\":123,\"InvertedIndex\":{\"Twenty-seven\":[0],\"metastatic\":[1,45],\"breast\":[2],\"adenocarcinoma\":[3],\"patients,\":[4]}}"
}
在indexed_abstract 中我们有一个InvertedIndex,其中包含一些关键字以及这些关键字在ObjectID 中出现的次数。
现在我想通过使用 bigquery 解析 json 来访问字符串化的 json,并且对于每个 ObjectID,我想创建一个嵌套字段,其中包含关键字、对应数组和对应数组的长度。
例如,在这种情况下,输出将如下所示:
+------------+----------------+---------------+-------------------+
| ObjectID | keyword.key | keyword.count | keyword.positions |
+------------+----------------+---------------+-------------------+
| 1984931229 | Twenty-seven | 1 | [0] |
| | metastatic | 2 | [1,45] |
| | breast | 1 | [2] |
| | adenocarcinoma | 1 | [3] |
| | patients | 1 | [4] |
+------------+----------------+---------------+-------------------+
我知道我可以使用 JSON_EXTRACT 函数,但我不确定我在倒排索引中访问关键字和与它们对应的数组的键是什么。
【问题讨论】:
标签: json google-bigquery json-extract