From 1d3ddc9a197e75d0e3488233adc11da6056fc903 Mon Sep 17 00:00:00 2001 From: Michael French Date: Fri, 8 Sep 2023 08:13:26 -0500 Subject: [PATCH] Athena: make statement type dependent on query command (#6786) --- moto/athena/responses.py | 6 +++++- tests/test_athena/test_athena.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/moto/athena/responses.py b/moto/athena/responses.py index e8b21e188..5bdc38c60 100644 --- a/moto/athena/responses.py +++ b/moto/athena/responses.py @@ -55,11 +55,15 @@ class AthenaResponse(BaseResponse): def get_query_execution(self) -> str: exec_id = self._get_param("QueryExecutionId") execution = self.athena_backend.get_query_execution(exec_id) + ddl_commands = ("ALTER", "CREATE", "DESCRIBE", "DROP", "MSCK", "SHOW") + statement_type = "DML" + if execution.query.upper().startswith(ddl_commands): + statement_type = "DDL" result = { "QueryExecution": { "QueryExecutionId": exec_id, "Query": execution.query, - "StatementType": "DDL", + "StatementType": statement_type, "ResultConfiguration": execution.config, "QueryExecutionContext": execution.context, "Status": { diff --git a/tests/test_athena/test_athena.py b/tests/test_athena/test_athena.py index 1f3644061..af2973f06 100644 --- a/tests/test_athena/test_athena.py +++ b/tests/test_athena/test_athena.py @@ -140,7 +140,7 @@ def test_get_query_execution(): # assert details["QueryExecutionId"] == exex_id assert details["Query"] == query - assert details["StatementType"] == "DDL" + assert details["StatementType"] == "DML" assert details["ResultConfiguration"]["OutputLocation"] == location assert details["QueryExecutionContext"]["Database"] == database assert details["Status"]["State"] == "SUCCEEDED"