From 768f5eea0fd917e41e4d00eb1bb9cf3614cf3f0e Mon Sep 17 00:00:00 2001 From: Scott Huang Date: Wed, 14 Aug 2024 02:42:09 +0800 Subject: [PATCH] Address comments --- metaphor/unity_catalog/extractor.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/metaphor/unity_catalog/extractor.py b/metaphor/unity_catalog/extractor.py index 52052bb6..4a65e3a3 100644 --- a/metaphor/unity_catalog/extractor.py +++ b/metaphor/unity_catalog/extractor.py @@ -235,12 +235,14 @@ def _get_catalogs(self) -> List[str]: catalog_names = [] for catalog in catalogs: - if catalog.name: - catalog_names.append(catalog.name) + if catalog.name is None: + continue + + catalog_names.append(catalog.name) if not catalog.owner: continue - hierarchy = self._assert_hierarchy(catalog.name) + hierarchy = self._init_hierarchy(catalog.name) hierarchy.system_contacts = SystemContacts( contacts=[ SystemContact( @@ -262,7 +264,7 @@ def _get_schemas(self, catalog: str) -> List[str]: if not schema.owner: continue - hierarchy = self._assert_hierarchy(catalog, schema.name) + hierarchy = self._init_hierarchy(catalog, schema.name) hierarchy.system_contacts = SystemContacts( contacts=[ SystemContact( @@ -492,7 +494,7 @@ def collect_query_logs(self) -> Iterator[QueryLog]: ): yield query_log - def _assert_hierarchy( + def _init_hierarchy( self, catalog: str, schema: Optional[str] = None, @@ -511,11 +513,11 @@ def _assert_hierarchy( def _extract_hierarchies(self, catalog_system_tags: CatalogSystemTags) -> None: for catalog, (catalog_tags, schema_name_to_tag) in catalog_system_tags.items(): if catalog_tags: - hierarchy = self._assert_hierarchy(catalog) + hierarchy = self._init_hierarchy(catalog) hierarchy.system_tags = SystemTags(tags=catalog_tags) for schema, schema_tags in schema_name_to_tag.items(): if schema_tags: - hierarchy = self._assert_hierarchy(catalog, schema) + hierarchy = self._init_hierarchy(catalog, schema) hierarchy.system_tags = SystemTags(tags=schema_tags) def _fetch_catalog_system_tags(self, catalog: str) -> CatalogSystemTagsTuple: