in lambda/auto-rbr-generate/query_actions.py [0:0]
def run_queries(queryList):
for q in queryList.keys():
transformedQuery = queryList[q]['Query'].replace("glueDBName",glueDBName).replace("pXX",pXX)
r = athena_client.start_query_execution(
QueryString=transformedQuery,
WorkGroup=workGroupName
)
queryList[q]['Id'] = r['QueryExecutionId']
#print (queryList)
print("Wait until all Athena Queries complete")
pendingQueries = []
for q in queryList.keys():
pendingQueries.append(queryList[q]['Id'])
while (pendingQueries != []):
for q in queryList.keys():
id = queryList[q]['Id']
if id in pendingQueries:
queryReturn = athena_client.get_query_execution(
QueryExecutionId=id)
queryStatus = queryReturn['QueryExecution']['Status']['State']
if queryStatus in ['FAILED','CANCELLED']:
print ("ERROR")
raise ("AthenaQueryReturnedError")
elif queryStatus == 'SUCCEEDED':
#print (queryReturn)
pendingQueries.remove(id)
time.sleep(1)
return (queryList)