javascript - 如何在 Amazon Athena 上查询(搜索)具有 JSON 值的 sql?

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

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

Screenshot of the data of Athena:

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

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

最佳答案

我假设 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 的更多信息.

关于javascript - 如何在 Amazon Athena 上查询(搜索)具有 JSON 值的 sql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55176767/

相关文章:

java - 如何从 Jsp 页面 (Web) 调用 Jbutton(Swing)?

MySQL:查询具有特定列值的记录组

php - 为什么当我合并 mysql 数据库中的表时,值是重复的?

javascript - 如何取消挂起的 Jquery Ajax 调用?

javascript - IndexedDB 的 JayData saveChanges() 错误

java - 在 JFrame 中使用 Darcula LAF

java - 在 Java 中,有时方法参数的行为类似于通过引用传递,尽管事实并非如此。他们通过什么方法?

JavaFx 将实体模型绑定(bind)到 TableView

javascript - 如何创建一个监听每种类型事件的监听器

javascript - DIV高度为另一个div下剩余空间的100%