def METHOD_NAME(session, params, wait = True):
    client = session.client('athena')
    ## This function executes the query and returns the query execution ID
    response_query_execution_id = client.start_query_execution(
        QueryString = params['query'],
        QueryExecutionContext = {
            'Database' : "default"
        }
    )
    if not wait:
        return response_query_execution_id['QueryExecutionId']
    else:
        response_get_query_details = client.get_query_execution(
            QueryExecutionId = response_query_execution_id['QueryExecutionId']
        )
        status = 'RUNNING'
        iterations = 360 # 30 mins
        while (iterations > 0):
            iterations = iterations - 1
            response_get_query_details = client.get_query_execution(
            QueryExecutionId = response_query_execution_id['QueryExecutionId']
            )
            res = response_get_query_details['QueryExecution']
            status = response_get_query_details['QueryExecution']['Status']['State']
            print(status)
            if (status == 'FAILED') or (status == 'CANCELLED') :
                response = response_get_query_details['QueryExecution']['Status']['StateChangeReason']
                return status, response
            elif status == 'SUCCEEDED':
                location = response_get_query_details['QueryExecution']['ResultConfiguration']['OutputLocation']
                ## Function to get output results
                response_query_result = client.get_query_results(
                    QueryExecutionId = response_query_execution_id['QueryExecutionId']
                )
                result_data = response_query_result['ResultSet']
                if len(response_query_result['ResultSet']['Rows']) > 1:
                    header = response_query_result['ResultSet']['Rows'][0]
                    rows = response_query_result['ResultSet']['Rows'][1:]
                    return location, status
                else:
                    return location, "No rows"
            else:
                time.sleep(5)
    return False