I am using Boto3 to read the results of my Athena query in a python script.
I have the following code that works fine in AWS Lambda.
def get_athena_results(s3_bucket, s3_output_path, execution_id):
s3client = boto3.client('s3')
key = s3_output_path + '/' + execution_id + '.csv'
obj = s3client.get_object(Bucket=s3_bucket, Key=key)
results_iterator = obj['Body'].iter_lines()
results = [r for r in results_iterator]
return results
When I run the same function in AWS Glue Python Shell (Not a Spark job), I get the error:
Unexpected error: <class 'AttributeError'>
'StreamingBody' object has no attribute 'iter_lines'
This doesn't make sense to me as the botocore.response.StreamingBody
class has an iter_lines
method, and it works fine in AWS Lambda.
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/response.html
Any idea why this is happening in AWS Glue Python Shell?
Thanks