首页 > 解决方案 > 如何通过 boto3 获取对 athena 的查询错误?

问题描述

如果查询失败,boto3 是否有任何方法允许获取错误文本?get_query_execution仅返回查询的状态。

标签: amazon-web-servicesboto3amazon-athena

解决方案


'StateChangeReason'您可以从response['Status'].

根据get_query_execution文档:

StateChangeReason (string) -- 有关查询状态的更多详细信息。

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'])

推荐阅读