【问题标题】:how to query(search) of sql on Amazon Athena which has JSON value?如何在 Amazon Athena 上查询(搜索)具有 JSON 值的 sql?
【发布时间】:2019-08-06 04:32:00
【问题描述】:

[查询时出现第一个错误][1]

select * from table where properties 'year' = 2007 // is not working
//please check the screen shot of the table

我想通过 sql 查询查询 Athena 数据集。我尝试了每个查询,但它不适用于此 Athena 数据

【问题讨论】:

标签: javascript java mysql amazon-web-services amazon-athena


【解决方案1】:

我假设properties 列是STRING,在这种情况下,您可以这样做来提取year 字段并在过滤器中使用它:

SELECT * FROM table WHERE JSON_EXTRACT_SCALAR(properties, '$.year') = '2007'

请注意,它是 '2007',而不是 2007,因为从您的屏幕截图来看,这些值看起来像是字符串。

您可以阅读有关JSON_EXTRACT_SCALAR function and other JSON manipulation functions in the documentation for the Presto version that Athena is currently using 的更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    • 2019-08-25
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多