查询BigQuery中的JSON值
我有一个BigQuery表(“活动”),其中一个列(“组”)包含一个JSON值(该表是Google Workspace日志的导出)。
我希望能够根据 group> group
列中的 group_email
JSON值从表中选择行。我检查了docs
SELECT
record_type,
email,
JSON_VALUE('groups.group_email') AS group_email
但是无效。我还尝试使用 group_email
的列索引,
SELECT
record_type,
email,
JSON_VALUE('groups[4]') AS group_email
但没有运气。我尝试了这些相同的组合作为Where语句的一部分,但得到了相同的结果:
SELECT
*
FROM
`company.workspace_prod.activity`
WHERE
record_type = 'groups'
and
JSON_VALUE('groups.group_email') = '[email protected]'
LIMIT
10
我还看到此答案但是使用 JSON_EXTRACT_SCALAR('组',“ $ .groups [0] .group_email')作为group_email
也返回
任何我的想法我做错了吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试以下方法。
您可以参考此 json函数文档以获取更多详细信息。
请使用JSON_VALUE的正确语法请参阅下面我的测试的屏幕截图。
示例数据:
查询结果:
You may try below approach.
You may refer to this JSON function Documentation for more details.
Please see screenshot of my testing below using the correct syntax for JSON_VALUE.
SAMPLE DATA:
QUERY RESULT:
虽然我迟到了,但我能够通过
though I am late but I am able to get via