Loading and unloading JSON files using AWS Athena

Viewed 28

I'm trying to load, filter and unload some json files using AWS Athena:

CREATE EXTERNAL TABLE IF NOT EXISTS
json_based_table(file_line string)
LOCATION 's3://<my_bucket>/<some_path/';

UNLOAD
(SELECT file_line from json_based_table limit 10)
TO 's3://<results_bucket>/samples/'
WITH (format = 'JSON');

Problem is the output is a set of files containing a json per line that has a single key "file_line" who's value is a json line from the original file as a string.

How do I UNLOAD such a table values only? (ignoring the column name I had to create to load the files)

1 Answers

It seems that by choosing

WITH (format = 'TEXTFILE');

I can get what I want. Choosing JSON as a format is good for preserving the tabular structure of the table in a file and was a misleading name in this case.

Related