Skip to content

Commit

Permalink
ADAP-1167: Add table format telemetry reporting to Athena adapter (#403)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Alfare <[email protected]>
  • Loading branch information
VanTudor and mikealfare authored Jan 30, 2025
1 parent ec443bd commit 76a51bf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dbt-athena/src/dbt/adapters/athena/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,3 +1452,14 @@ def _run_query(self, sql: str, catch_partitions_limit: bool) -> AthenaCursor:
LOGGER.debug(f"CAUGHT EXCEPTION: {e}")
raise e
return cursor

@classmethod
def _get_adapter_specific_run_info(cls, config: RelationConfig) -> Dict[str, Any]:
try:
table_format = config._extra.get("table_type")
except AttributeError:
table_format = None
return {
"adapter_type": "athena",
"table_format": table_format,
}
3 changes: 3 additions & 0 deletions dbt-athena/tests/functional/adapter/test_retries_iceberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
seeds__expected_target_post = "id,status\n" + "\n".join([f"{i},{i}" for i in range(PARALLELISM)])


@pytest.mark.skip(
reason="Unreliable test in practice. No apparent reliable way to trigger a retry, which causes the test to fail. Disabled until we get a resolution here https://github.com/dbt-labs/dbt-athena/pull/657/files#r1922043351"
)
class TestIcebergRetriesDisabled:
@pytest.fixture(scope="class")
def dbt_profile_target(self):
Expand Down
28 changes: 28 additions & 0 deletions dbt-athena/tests/unit/test_adapter_telemetry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from unittest import mock

import dbt.adapters.athena.__version__

from dbt.adapters.athena.impl import AthenaAdapter
from dbt.adapters.base.relation import AdapterTrackingRelationInfo


def test_telemetry_with_athena_details():
mock_model_config = mock.MagicMock()
mock_model_config._extra = mock.MagicMock()
mock_model_config._extra = {
"adapter_type": "athena",
"table_type": "iceberg",
}

res = AthenaAdapter.get_adapter_run_info(mock_model_config)

assert res.adapter_name == "athena"
assert res.base_adapter_version == dbt.adapters.__about__.version
assert res.adapter_version == dbt.adapters.athena.__version__.version

assert res.model_adapter_details == {
"adapter_type": "athena",
"table_format": "iceberg",
}

assert isinstance(res, AdapterTrackingRelationInfo)

0 comments on commit 76a51bf

Please sign in to comment.