Athena: make statement type dependent on query command (#6786)
This commit is contained in:
parent
056b69bee7
commit
1d3ddc9a19
@ -55,11 +55,15 @@ class AthenaResponse(BaseResponse):
|
|||||||
def get_query_execution(self) -> str:
|
def get_query_execution(self) -> str:
|
||||||
exec_id = self._get_param("QueryExecutionId")
|
exec_id = self._get_param("QueryExecutionId")
|
||||||
execution = self.athena_backend.get_query_execution(exec_id)
|
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 = {
|
result = {
|
||||||
"QueryExecution": {
|
"QueryExecution": {
|
||||||
"QueryExecutionId": exec_id,
|
"QueryExecutionId": exec_id,
|
||||||
"Query": execution.query,
|
"Query": execution.query,
|
||||||
"StatementType": "DDL",
|
"StatementType": statement_type,
|
||||||
"ResultConfiguration": execution.config,
|
"ResultConfiguration": execution.config,
|
||||||
"QueryExecutionContext": execution.context,
|
"QueryExecutionContext": execution.context,
|
||||||
"Status": {
|
"Status": {
|
||||||
|
@ -140,7 +140,7 @@ def test_get_query_execution():
|
|||||||
#
|
#
|
||||||
assert details["QueryExecutionId"] == exex_id
|
assert details["QueryExecutionId"] == exex_id
|
||||||
assert details["Query"] == query
|
assert details["Query"] == query
|
||||||
assert details["StatementType"] == "DDL"
|
assert details["StatementType"] == "DML"
|
||||||
assert details["ResultConfiguration"]["OutputLocation"] == location
|
assert details["ResultConfiguration"]["OutputLocation"] == location
|
||||||
assert details["QueryExecutionContext"]["Database"] == database
|
assert details["QueryExecutionContext"]["Database"] == database
|
||||||
assert details["Status"]["State"] == "SUCCEEDED"
|
assert details["Status"]["State"] == "SUCCEEDED"
|
||||||
|
Loading…
Reference in New Issue
Block a user