使用boto3 Redshift Client的describe_statement接口未返回Error字段,无法定位SQL执行失败原因求助
boto3 Redshift Client的describe_statement接口未返回Error字段,无法定位SQL执行失败原因求助
我通过boto3的Redshift客户端调用execute_statement执行了一条SQL查询,之后用describe_statement接口查询语句状态,结果显示执行失败,我正试图排查原因。这条SQL语句是没问题的,我已经在其他工具里验证过了。
我的代码如下:
result = client_redshift.execute_statement(Database= 'my_database', SecretArn= secret_arn, Sql= query_str, ClusterIdentifier= cluster_id, ResultFormat = "CSV") response = client_redshift.describe_statement(Id = result["Id"]) if response["Status"] == "FINISHED": data = client_redshift.get_statement_result(Id = result["Id"]) break if response["Status"] == "FAILED": print(response.keys())
状态显示为FAILED,但我找不到具体的错误信息。根据boto3 1.35.79版本的文档,describe_statement在执行失败时返回的结果里应该包含"Error"字段,但实际返回的键里并没有这个字段。
boto3文档说明:
而我实际打印response.keys()得到的结果是:
dict_keys(['ClusterIdentifier', 'CreatedAt', 'Database', 'Duration', 'HasResultSet', 'Id', 'QueryString', 'RedshiftPid', 'RedshiftQueryId', 'ResultFormat', 'ResultRows', 'ResultSize', 'SecretArn', 'Status', 'UpdatedAt', 'ResponseMetadata'])
在我去Github提交issue之前,想请教下是不是我哪里考虑不周或者忽略了什么细节?
备注:内容来源于stack exchange,提问作者tonneofash




