2 個答案
- 最新
- 最多得票
- 最多評論
1
I generally use the following steps.
- get all query ID's
- get the query details for each query ID
- check if its the right one & do something
Code:
Get Athena client/object
client = boto3.client('athena')
# Get all the saved queries in Athena
response = client.list_named_queries()
# Get the named query IDs from the response
named_query_IDs = response['NamedQueryIds']
# Go through all the query ID, to find the delete & create queries we need to run
for query_ID in named_query_IDs:
# Get all the details of a named query using its ID
named_query = client.get_named_query(
NamedQueryId=query_ID
)
# Get the query string & query name of the query
querystring = named_query['NamedQuery']['QueryString']
queryname = named_query['NamedQuery']['Name']
# If its a create query, add it to the list of create queries
# We also replace the '/subfolder' string in the query with the folder structure for the current month
if 'create_linked_' in queryname:
new_query = querystring.replace('/subfolder', currentmonth)
create_query_strings.append(new_query)
# If its a delete query, add it to the list of delete queries to execute later
if 'delete_linked_' in queryname:
delete_query_strings.append(querystring)
1
Please check out the section from ** AWS Well-Architected Labs** ,
CREATE LAMBDA FUNCTION TO RUN THE SAVED QUERIES
已回答 2 年前
相關內容
- 已提問 1 年前
- 已提問 7 個月前
- AWS 官方已更新 1 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前