如何在具有 JSON 值的 Amazon Athena 上查询(搜索)sql?
how to query(search) of sql on Amazon Athena which has JSON value?
[查询时出现第一个错误][1]
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
,因为从您的屏幕截图来看,这些值看起来像是字符串。
[查询时出现第一个错误][1]
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
,因为从您的屏幕截图来看,这些值看起来像是字符串。