user3876608
user3876608

Reputation: 121

How to get an error of query to athena via boto3?

Does boto3 have any method which allows one to get the text of the error if the query failed? get_query_execution returns a status of the query only.

Upvotes: 1

Views: 2790

Answers (1)

taras
taras

Reputation: 6915

You can get the error message from 'StateChangeReason' field of your response['Status'].

As per get_query_execution documentation:

StateChangeReason (string) -- Further detail about the status of the query.

import boto3

client = boto3.client('athena')

failed_query_id = '08adbf00-5f14-4d54-9311-fd55e2024781'
response = client.get_query_execution(QueryExecutionId=failed_query_id)
print(response['Status']['StateChangeReason'])

Upvotes: 7

Related Questions