我想从 AWS 中的 Athena 获取结果值格式 JSON。
当我从 Athena 中选择时,结果格式是这样的。
{test.value={report_1=test, report_2=normal, report_3=hard}}
有没有办法在不将 "=" 替换为 ":" 的情况下获得 JSON 格式的结果?
列格式为
map<string,map<string,string>>
我想从 AWS 中的 Athena 获取结果值格式 JSON。
当我从 Athena 中选择时,结果格式是这样的。
{test.value={report_1=test, report_2=normal, report_3=hard}}
有没有办法在不将 "=" 替换为 ":" 的情况下获得 JSON 格式的结果?
列格式为
map<string,map<string,string>>
select mycol
from mytable
;
+--------------------------------------------------------------+
| mycol |
+--------------------------------------------------------------+
| {test.value={report_3=hard, report_2=normal, report_1=test}} |
+--------------------------------------------------------------+
select cast (mycol as json) as json
from mytable
;
+--------------------------------------------------------------------------+
| json |
+--------------------------------------------------------------------------+
| {"test.value":{"report_1":"test","report_2":"normal","report_3":"hard"}} |
+--------------------------------------------------------------------------+
如果您的输入格式是 json(即您的整行是 JSON),您可以创建一个新表来保存您指定的任何格式的 athena 结果,如 parquet、json、orc 等。这最终将存储所有 athena您的查询结果,在具有所需格式的 s3 存储桶中。
希望这可以帮助
这是供参考的文档:https ://docs.aws.amazon.com/athena/latest/ug/ctas-examples.html