diff --git a/pyathena/result_set.py b/pyathena/result_set.py index c24b749f..5010dd97 100644 --- a/pyathena/result_set.py +++ b/pyathena/result_set.py @@ -56,6 +56,7 @@ class AthenaResultSet(CursorIterator): # https://docs.aws.amazon.com/athena/latest/ug/data-types.html # Athena complex types that benefit from type hint conversion. _COMPLEX_TYPES: frozenset[str] = frozenset({"array", "map", "row", "struct"}) + _DML_SUBSTATEMENT_TYPES: frozenset[str] = frozenset({"INSERT", "UPDATE", "DELETE", "MERGE"}) def __init__( self, @@ -318,7 +319,10 @@ def result_reuse_minutes(self) -> int | None: def description( self, ) -> list[tuple[str, str, None, None, int, int, str]] | None: - if self._metadata is None: + if self._metadata is None or ( + self.substatement_type + and self.substatement_type.upper() in self._DML_SUBSTATEMENT_TYPES + ): return None return [ ( diff --git a/tests/pyathena/test_cursor.py b/tests/pyathena/test_cursor.py index f7d84638..2e3c2be3 100644 --- a/tests/pyathena/test_cursor.py +++ b/tests/pyathena/test_cursor.py @@ -826,6 +826,7 @@ def test_iceberg_table(self, cursor): VALUES (1, 'test1'), (2, 'test2') """ ) + assert cursor.description is None assert cursor.rowcount == 2 cursor.execute( f""" @@ -842,6 +843,7 @@ def test_iceberg_table(self, cursor): WHERE id = 1 """ ) + assert cursor.description is None assert cursor.rowcount == 1 cursor.execute( f""" @@ -873,6 +875,7 @@ def test_iceberg_table(self, cursor): THEN UPDATE SET col1 = t2.col1 """ ) + assert cursor.description is None assert cursor.rowcount == 1 cursor.execute( f""" @@ -895,6 +898,7 @@ def test_iceberg_table(self, cursor): WHERE id = 2 """ ) + assert cursor.description is None assert cursor.rowcount == 1 cursor.execute( f""" diff --git a/tests/sqlalchemy/test_suite.py b/tests/sqlalchemy/test_suite.py index 4ffdd9cc..49077eef 100644 --- a/tests/sqlalchemy/test_suite.py +++ b/tests/sqlalchemy/test_suite.py @@ -21,7 +21,6 @@ del LongNameBlowoutTest # noqa: F821 del QuotedNameArgumentTest # noqa: F821 del RowCountTest # noqa: F821 -del SimpleUpdateDeleteTest # noqa: F821 del TimeMicrosecondsTest # noqa: F821 del TimeTest # noqa: F821 del TimestampMicrosecondsTest # noqa: F821