I am working on python lambda functions that will shoot a sql query to Athena as part of my process. The development part is done, i need to test my code, where i use moto for testing my lambda functions locally. 70% of my lambda function is sql code, is there a chance i get to moto support aws athena? Thanks.
As a general rule, new endpoints get added when people that need them have some extra time to add them to Moto.
Right now I don't have a particular use for this so I can't promise anything for timing.
If someone does have time, pull requests are much appreciated (even small one just to get a service started). If you have some example code you want to work, preferably with some example data, that can also speed up the process.
+1 For Athena support.
We are using Athena within more and more of our projects, and the ability to maintain full test coverage would be awesome.
Thanks for your contributions thus far, and keep up the good work !
+1
My team have increased our use of Athena massively recently but have struggled when it comes to testing our solutions locally.
Adding Athena support to moto would be a great addition to an already powerful library.
+1 from me too
+1
+1
Moto already has these methods:
list_work_groups
What other methods would people like to see?
(Just trying to get a feel for what's most used, in case I want to have a crack at it..)
This is a comprehensive list: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html
But the most important ones are:
get_query_execution()get_query_results()start_query_execution()stop_query_execution()@bblommers I see that start_query_execution(), stop_query_execution() and get_query_execution() have been implemented and merged in #2996 (thanks for implementing them) but for now the query stays in the QUEUED status indefinitely unless explicitly stopped, after which it passes to CANCELLED.
Me and my team would be interested in having a way of testing also around other states (RUNNING, SUCCEEDED, and FAILED) and we would be available to dedicate some time to do a PR but we are not sure of what would be an acceptable way of extending the AthenaBackend without making a blocking action (thinking of a time.sleep()) or having to actually implement an actual query execution.
I have checked how similar cases are handled in moto for DynamoDB Tables or EC2 Instances and in both cases the transition is skipped altogether in favor of the end state.
Hi @dreamorosi, are you using the decorators? Most people fiddle with the state directly in their tests, if they have a specific use case. See this comment from spulec: https://github.com/spulec/moto/issues/380#issuecomment-123932483
Hi @bblommers, thanks for the reply! I will try the option suggested in that issue but from a first look it seems it could fit our needs. I'll comment here in case it doesn't and we can discuss further.
throwing another vote for "SUCCEEDED" being the final state. most of my test suite relies on this case, and the tests that check other states can do manual intervention, as in #380
Edit: this is what I settled on as a global mock
@pytest.fixture(autouse=True)
def set_all_moto_athena_queries_as_successful(
monkeypatch: MonkeyPatch,
) -> Generator[MagicMock, None, None]:
"""Handle https://github.com/spulec/moto/issues/1524."""
class SuccessfullerExecution(moto.athena.models.Execution): # type: ignore
def __init__(
self: SuccessfullerExecution,
query: str,
context: str,
config: str,
workgroup: str,
) -> None:
super().__init__(query, context, config, workgroup)
self.status = "SUCCEEDED"
with patch("moto.athena.models.Execution", new=SuccessfullerExecution) as mocked:
yield mocked
Most helpful comment
This is a comprehensive list: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html
But the most important ones are:
get_query_execution()get_query_results()start_query_execution()stop_query_execution()