【发布时间】:2022-11-03 03:39:35
【问题描述】:
我开始使用 AWS Data Wrangler lib (https://aws-data-wrangler.readthedocs.io/en/stable/what.html)
在 AWS Athena 上执行查询并在我的 AWS Glue python shell 作业中使用它们的结果。
我看到存在 wr.athena.read_sql_query 以获得我需要的东西。
这是我的代码:
import sys
import os
import awswrangler as wr
os.environ['AWS_DEFAULT_REGION'] = 'eu-west-1'
databases = wr.catalog.databases()
print(databases)
query='select count(*) from staging_dim_channel'
print(query)
df_res = wr.athena.read_sql_query(sql=query, database="lsk2-target")
print(df_res)
print(f'DataScannedInBytes: {df_res.query_metadata["Statistics"]["DataScannedInBytes"]}')
print(f'TotalExecutionTimeInMillis: {df_res.query_metadata["Statistics"]["TotalExecutionTimeInMillis"]}')
print(f'QueryQueueTimeInMillis: {df_res.query_metadata["Statistics"]["QueryQueueTimeInMillis"]}')
print(f'QueryPlanningTimeInMillis: {df_res.query_metadata["Statistics"]["QueryPlanningTimeInMillis"]}')
print(f'ServiceProcessingTimeInMillis: {df_res.query_metadata["Statistics"]["ServiceProcessingTimeInMillis"]}')
我毫无问题地检索了数据库列表(包括 lsk2-target),但是 read_sql_query 继续出错并且我收到:
WaiterError: Waiter BucketExists failed: Max attempts exceeded
拜托,你能帮我理解我错在哪里吗? 谢谢!
【问题讨论】:
-
我解决了使用 Boto3 for Athena
标签: amazon-web-services aws-glue amazon-athena