diff --git a/metadata_service/proxy/atlas_proxy.py b/metadata_service/proxy/atlas_proxy.py index eab3c6a4..a981e485 100644 --- a/metadata_service/proxy/atlas_proxy.py +++ b/metadata_service/proxy/atlas_proxy.py @@ -1,7 +1,7 @@ import logging import re from random import randint -from typing import Any, Dict, List, Union +from typing import Any, Dict, List, Union, Optional from amundsen_common.models.popular_table import PopularTable from amundsen_common.models.table import Column, Statistics, Table, Tag, User @@ -378,7 +378,7 @@ def get_table(self, *, table_uri: str) -> Table: description=attrs.get('description') or attrs.get('comment'), owners=[User(email=attrs.get('owner'))], columns=columns, - last_updated_timestamp=table_details.get('updateTime')) + last_updated_timestamp=self._parse_date(table_details.get('updateTime'))) return table except KeyError as ex: @@ -633,6 +633,17 @@ def _delete_table_relation_by_user(self, *, entity.entity[self.ATTRS_KEY][self.BOOKMARK_ACTIVE_KEY] = False entity.update() + def _parse_date(self, date: int) -> Optional[int]: + try: + date_str = str(date) + date_trimmed = date_str[:10] + + assert len(date_trimmed) == 10 + + return int(date_trimmed) + except Exception: + return None + def get_dashboard(self, dashboard_uri: str, ) -> DashboardDetailEntity: diff --git a/tests/unit/proxy/fixtures/atlas_test_data.py b/tests/unit/proxy/fixtures/atlas_test_data.py index 308d4b1e..8b94aab0 100644 --- a/tests/unit/proxy/fixtures/atlas_test_data.py +++ b/tests/unit/proxy/fixtures/atlas_test_data.py @@ -74,7 +74,7 @@ class Data: db_entity = { 'guid': '-100', - 'updateTime': 234, + 'updateTime': 2345678901234, 'typeName': entity_type, 'attributes': { 'qualifiedName': db, @@ -87,7 +87,7 @@ class Data: entity1 = { 'guid': '1', 'typeName': entity_type, - 'updateTime': 123, + 'updateTime': 1234567890123, 'attributes': { 'qualifiedName': '{}.{}@{}'.format(db, 'Table1', cluster), 'name': 'Table1', diff --git a/tests/unit/proxy/test_atlas_proxy.py b/tests/unit/proxy/test_atlas_proxy.py index 916156cf..4db0d7a4 100644 --- a/tests/unit/proxy/test_atlas_proxy.py +++ b/tests/unit/proxy/test_atlas_proxy.py @@ -125,8 +125,8 @@ def _get_table(self, custom_stats_format: bool = False) -> None: tags=[Tag(tag_name=classif_name, tag_type="default")], description=ent_attrs['description'], owners=[User(email=ent_attrs['owner'])], - columns=[exp_col] * self.active_columns, - last_updated_timestamp=cast(int, self.entity1['updateTime'])) + last_updated_timestamp=int(str(self.entity1['updateTime'])[:10]), + columns=[exp_col] * self.active_columns) self.assertEqual(str(expected), str(response))