(This question is very similar to Store multiple elements in json files in AWS Athena)
I have a JSON file in an S3 bucket that is structured like this -
[{"key1": value, "key2": value, "key3": {"key4": value, etc}}, {"key1": value....}]
Two questions:
Why is it that if I send this directly to Quicksight, Quicksight knows to normalize the file perfectly (unless there are multiple files in the bucket that don't match (which is why I'm trying Athena)) but Athena struggles with it? I know it has something to do with formatting (each dictionary isn't on its own line, it's a list of dictionaries and not just dictionaries, etc) but it seems so unnecessary to modify the original file if there is another service on AWS that knows how to parse and flatten it without an issue.
I'm using a Python script in Lambda to call the API and the list of dictionaries is the format it comes in. Is there a simple way to format the JSON file in the way Athena likes? Below is an example of my current script -
response = requests.request(method, url, **kwargs)
data_dict = response.json()
data_json = json.dumps(data_dict['results'])
s3.Bucket('bucket_name').put_object(Key = key, Body = data_json)
Disclaimer: I am fairly new to AWS/coding in general and have encountered many challenges while trying to understand the AWS documentation, so my apologies if this is a simple fix.