Reset/Remove Static Athena Query Results #7681
Replies: 1 comment 2 replies
-
Hi @robwhiteston! To answer your question directly: No, there is currently no way to delete the static query results. However: The query results are stored in a queue, and are tied to the query execution ID's as they come in. So if you have So as long as you use three different query execution ID's, you should not have to worry about clashing results. Does that make sense, or am I misunderstanding the problem? |
Beta Was this translation helpful? Give feedback.
-
Before I get to the main question, a little context about what I am trying to do. At my company I have set up a AWS MWAA environment and I am using motoserver as a way to run integration tests against my DAG's locally, and AWS Glue and S3 its been working FANTASTIC. One important bit of information: I am not using the moto mocks in my pytest code. My tests are executing outside of the container and calling the airflow REST API with Airflow's api client.
I am setting our environment up to leverage the newish Athena SQL Connection provided by the the Amazon airflow provider. I read through how to set up static query results with the moto Athena backend and have successfully gotten my simple integration test to run green. Right now I have 3 pytest fixtures which each load a different static result into the static query results for Athena. All three basically look like this (I figured posting all three would create clutter):
Here is the integration test:
The Athena SQL Connection doesn't actually use the boto client, rather, it uses PyAthena for the DB API 2.0 support. So, there isn't anyway for me to predict what QueryExecutionId will be assigned to each of the three seeded query results. That is fine, so long as I can delete the static query results between test method executions. Is there a way for me to delete the static query results from the motoserver running inside my containerized environment? I don't want to call moto's reset endpoint because when the environment starts up I create a bunch of AWS resources in moto which other tests depend on.
It doesn't seem like there is a DELETE endpoint for the static query results resource in the api, so if thats the best way to do it for my situation I'll gladly work on a PR to add it. I feel like there must be a way to do this and I am just misunderstanding something.
Thanks!!
Oh, and FWIW, the DAG under test is just a simple dag meant to illustrate how to use the SQLExecuteQueryOperator, the SQLTableCheckOperator, and the SQLCheckOperator. I am also happy to post my docker-compose.yml file that shows how my environment is set up if that is helpful.
Beta Was this translation helpful? Give feedback.
All reactions