Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Athena map query

The table has a column like this,

data  MAP<string, string>

and rows like,

id | data
1  | {"foo": 123}
2  | {"bar": 456}

Then, how can i search data["bar"] = 456? I tried but it shows me the error "Column 'bar' cannot be resolved"

like image 245
yountae.kang Avatar asked Oct 12 '17 02:10

yountae.kang


People also ask

What is map in Athena?

Maps are key-value pairs that consist of data types available in Athena. To create maps, use the MAP operator and pass it two arrays: the first is the column (key) names, and the second is values. All values in the arrays must be of the same type.

Does AWS Athena use SQL?

Amazon Athena uses Presto with ANSI SQL support and works with a variety of standard data formats, including CSV, JSON, ORC, Avro, and Parquet.

How do I read an array in Athena?

To access the elements of an array at a given position (known as the index position), use the element_at() function and specify the array name and the index position: If the index is greater than 0, element_at() returns the element that you specify, counting from the beginning to the end of the array.

How do I run multiple queries in Athena?

Open the Amazon Athena console at https://console.aws.amazon.com/athena/ . In the left navigation pane, choose Workflows. In the Execute multiple queries tile, choose Get started. In the Get started dialog box, choose Deploy a sample project, and then choose Continue.


1 Answers

I found i was wrong. " shouldn't be used in query. ' should be used! so,

WHERE data['foo'] = 123

will be worked.

like image 65
yountae.kang Avatar answered Sep 28 '22 00:09

yountae.kang