Hive select 来自 json 行的特定字符串

Hive select a particular string from a json row

我正在尝试分析 Athena 中的 AWS 云跟踪日志,为此如果我 select 安全组添加 入站规则事件 它 returns 下面的字符串在 元素列中

{"groupId":"sg-XXXX","ipPermissions":{"items":[{"ipProtocol":"tcp","fromPort":22,"toPort":22,"groups":{},"ipRanges":{"items":[{"cidrIp":"0.0.0.0/0"}]},"prefixListIds":{}}]}}

但是 json 结果中我只需要 groupId。那我怎么才能得到呢?

Note: The tables is an external table

select json_extract_scalar('{"groupId":"sg-XXXX","ipPermissions":{"items":[{"ipProtocol":"tcp","fromPort":22,"toPort":22,"groups":{},"ipRanges":{"items":[{"cidrIp":"0.0.0.0/0"}]},"prefixListIds":{}}]}}','$.groupId');
OK
sg-XXXX