Amazon athena can’t read S3 JSON Object files and Athena select query returns empty result sets for JSON key columns

Question:

I create a table in Athena with below structure

S3 bucket objects contains JSON structure like this

However below SQL working correctly and return the correct result for only count

BUT whenever I query below SQL select statement to fetch the
JSON values from S3, It’s returns result sets with empty values for columns

enter image description here

Also, I review these links before post this question on StackOverflow and AWS Athena doc

Can’t read json file via Amazon Athena

AWS Athena json_extract query from string field returns empty values

Any comments or suggestions would be much appreciated.

Answer:

The JSON must be in a single line, as mentioned in this page of the AWS Athena documentation. You can have multiple JSON objects on separate lines, but each complete object must only span one line.

Example (this could all be in one S3 object):

Leave a Reply