InvalidRequestException upon using get_query_results despite getting HTTPStatusCode: 200 when I ran start_query_execution previously

hahilas

I am trying to execute an AWS Athena query in my Jupyter notebook and also retrieve the results using Boto3.

I first ran this to execute my query:

response1 = client.start_query_execution(
    QueryString= "SELECT date from my data_table LIMIT 1;",
    QueryExecutionContext={
        'Database': 'my_database',
        'Catalog': 'AwsDataCatalog'
    },
    ResultConfiguration={
        'OutputLocation': 's3://XXX/YYY/'
        
    }
)

The resultant output of the response is:

{'QueryExecutionId': 'abcd123456',
 'ResponseMetadata': {'RequestId': 'efgh123456',
  'HTTPStatusCode': 200,
  'HTTPHeaders': {'content-type': 'application/x-amz-json-1.1',
   'date': 'Mon, 05 Jul 2021 06:38:15 GMT',
   'x-amzn-requestid': 'ijklmn123456',
   'content-length': '59',
   'connection': 'keep-alive'},
  'RetryAttempts': 0}}

Next, I wanted to retrieve the results using the QueryExecutionId which is 'abcd123456' obtained above as shown below:

response2 = client.get_query_results(
    QueryExecutionId = 'abcd123456',
    MaxResults = 123
)

However, it throws me this error:

InvalidRequestException: An error occurred (InvalidRequestException) when calling the GetQueryResults operation: Query did not finish successfully. Final query state: FAILED

I wonder why does it say final query state is 'FAILED' when the HTTPStatusCode of the start_query_execution is 200. I did refer to this link (InvalidRequestException) when calling the GetQueryResults..... Querying Athena From Lambda Python.... Cannot Read Results but I couldn't solve my problem.

Would greatly appreciate if someone could help me with this!

hahilas

Turns out I can run the query and obtain the results when I changed my s3 output location. I guess I had limited permission to the previous s3 bucket path I used.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I get Ran out of input using multiprocessing and not when using threading

How to Create Dataframe from AWS Athena using Boto3 get_query_results method

Getting error :stream has already been operated upon or closed when I am using seperate streams

Getting 200 code when using sockets in Flask

I'm getting 404 when run it on terminal and getting 200 on idle

Getting error when I'm trying to get data from 3 table using sql INNER JOIN query

Why i m getting Ran out of input Error when i m running this code in python?

Why am I getting junk values despite using calloc()?

Not getting result when ran the Nashorn program

How can I filter on the type of query that I ran in Snowflake?

"Error getting endorser client for query" when trying cli interaction with hyperledger fabric example, despite successful installation

Getting "Whitelabel Error Page" when I ran a brand new spring boot project

Optimize frequently ran query

How to create a filename with the current date and time in python when query is ran

SQL OUTER JOIN query is asking for parameter when ran in Access

SQL Invalid identifier - only occurs when query is ran in script

Django - Query_set returns an empty arraylist when it is ran in the test

center previously floated content using a media query

Not allowed to return a result set from a trigger for the query I ran

Query Parameter is not getting matched when using WireMock

Getting error when using prepareStatement with interval in query

When scraping data, I get only first result despite using Array.from

Why is my subquery returning no results in my query but returns normally when ran on it's own?

Getting a HttpStatusCode of 0

Getting ConsumeContext not available when using MassTransit and Automatonymous Publish after previously using RaiseEvent

Why am I getting different results when using for and while loops?

Errors when I start the Python shell, errors from a script I ran a week ago

query returns different results when executed using get_results()

Why do I get back 2 responses of 200 and 204 when using an AJAX call to delete objects?