I wrote a script that would execute a query on Athena and load the result file in a specified aws boto S3 location.
import boto3
def run_query(query, database, s3_output):
client = boto3.client('athena', region_name='my-region')
response = client.start_query_execution(
QueryString=query,
QueryExecutionContext={
'Database': database
},
ResultConfiguration={
'OutputLocation': s3_output,
}
)
print('Execution ID: ' + response['QueryExecutionId'])
return response
query = """select ..."""
database = 'db_name'
path_template = 's3://bucket_name/path/version={}'
current_time = str(datetime.datetime.now())
result = run_query(query, database, path_template.format(current_time))
It does work but the problem is that I have a csv file as the specified location. But I don't want a csv file I want a parquet file.
The only way I manage to obtain what I want is to download the file convert it with panda to parquet to reupload it. It's annoying that I can't just convert directly without fetching the file.
Anyone has another way to suggest ? I don't want to use a CTAS.