Is it possible for Athena to UNLOAD
the results, and retain the key names?
This seems to be really inconsistent.
When I do not use UNLOAD, and use the default Athena -> S3 as CSV output, then the header columns retain the names as camelCase.
When I do use UNLOAD, and use the JSON format, the keys get flattened for the same query.
UNLOAD (
WITH dataset AS (
SELECT 'engineering' as department,
ARRAY [ 'Sharon',
'John',
'Bob',
'Sally' ] as users
)
SELECT department AS "departmentName",
names
FROM dataset
CROSS JOIN UNNEST(users) as t(names)
) TO 's3://${YOUR_BUCKET}/unload/' WITH (format = 'JSON')
Result:
{"departmentname":"engineering","names":"Sharon"}
{"departmentname":"engineering","names":"John"}
{"departmentname":"engineering","names":"Bob"}
{"departmentname":"engineering","names":"Sally"}