UNLOAD Athena query results as JSON with camelCase keys

0

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"}
profile picture
m0ltar
asked 10 months ago68 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions