雅典娜查询失败,并出现boto3(S3位置无效) [英] Athena query fails with boto3 (S3 location invalid)

查看:224
本文介绍了雅典娜查询失败,并出现boto3(S3位置无效)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Athena中执行查询,但是失败.

I'm trying to execute a query in Athena, but it fails.

代码:

client.start_query_execution(QueryString="CREATE DATABASE IF NOT EXISTS db;",
                           QueryExecutionContext={'Database': 'db'},
                           ResultConfiguration={
                                     'OutputLocation': "s3://my-bucket/",
                                     'EncryptionConfiguration': {
                                             'EncryptionOption': 'SSE-S3'
                                             }
                                     })

但是它引发了以下异常:

But it raises the following exception:

botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) 
when calling the StartQueryExecution operation: The S3 location provided to save your 
query results is invalid. Please check your S3 location is correct and is in the same 
region and try again. If you continue to see the issue, contact customer support 
for further assistance.

但是,如果我转到Athena控制台,请转到设置"并输入相同的S3位置(例如):

However, if I go to the Athena Console, go to Settings and enter the same S3 location (for example):

查询运行正常.

我的代码有什么问题?我已经成功使用了其他几个服务(例如S3)的API,但是我相信在此我传递了一些不正确的参数.谢谢.

What's wrong with my code? I've used the API of several the other services (eg, S3) successfully, but in this one I believe I'm passing some incorrect parameters. Thanks.

Python:3.6.1. Boto3:1.4.4

Python: 3.6.1. Boto3: 1.4.4

推荐答案

EDIT :正如Justin所建议的那样,AWS后来通过在存储桶中添加athena前缀来添加了对Athena的支持.请支持他的回答.

EDIT: As suggested by Justin, AWS later added support for Athena by adding athena prefix to the bucket. Please upvote his answer.

接受的答案:

为保存查询结果而提供的S3位置无效. 请检查您的S3位置是否正确并且在同一地区,然后重试.

The S3 location provided to save your query results is invalid. Please check your S3 location is correct and is in the same region and try again.

由于使用控制台时可以正常使用,因此存储桶可能与Boto3中使用的存储桶位于不同的区域.构造Boto3客户端时,请确保使用正确的区域(在控制台中可用的区域).默认情况下,Boto3将使用凭据文件中配置的区域.

Since it works when you use the console, it is likely the bucket is in a different region than the one you are using in Boto3. Make sure you use the correct region (the one that worked in the console) when constructing the Boto3 client. By default, Boto3 will use the region configured in the credentials file.

这篇关于雅典娜查询失败,并出现boto3(S3位置无效)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆