如何通过boto3查询athena错误?

use*_*608 0 amazon-web-services boto3 amazon-athena

boto3 是否有任何方法可以在查询失败时获取错误文本?get_query_execution仅返回查询的状态。

tar*_*ras 5

'StateChangeReason'您可以从的字段中获取错误消息response['Status']。

根据get_query_execution文档:

StateChangeReason(字符串)——有关查询状态的更多详细信息。

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'])
Run Code Online (Sandbox Code Playgroud)