|
40 | 40 | ) |
41 | 41 |
|
42 | 42 | from pyiceberg.catalog import ( |
43 | | - DEPRECATED_ACCESS_KEY_ID, |
44 | 43 | DEPRECATED_BOTOCORE_SESSION, |
45 | | - DEPRECATED_PROFILE_NAME, |
46 | | - DEPRECATED_REGION, |
47 | | - DEPRECATED_SECRET_ACCESS_KEY, |
48 | | - DEPRECATED_SESSION_TOKEN, |
49 | 44 | EXTERNAL_TABLE, |
50 | 45 | ICEBERG, |
51 | 46 | LOCATION, |
@@ -303,18 +298,12 @@ def __init__(self, name: str, **properties: Any): |
303 | 298 | super().__init__(name, **properties) |
304 | 299 |
|
305 | 300 | session = boto3.Session( |
306 | | - profile_name=get_first_property_value(properties, GLUE_PROFILE_NAME, DEPRECATED_PROFILE_NAME), |
307 | | - region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION, DEPRECATED_REGION), |
| 301 | + profile_name=properties.get(GLUE_PROFILE_NAME), |
| 302 | + region_name=get_first_property_value(properties, GLUE_REGION, AWS_REGION), |
308 | 303 | botocore_session=properties.get(DEPRECATED_BOTOCORE_SESSION), |
309 | | - aws_access_key_id=get_first_property_value( |
310 | | - properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID, DEPRECATED_ACCESS_KEY_ID |
311 | | - ), |
312 | | - aws_secret_access_key=get_first_property_value( |
313 | | - properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY, DEPRECATED_SECRET_ACCESS_KEY |
314 | | - ), |
315 | | - aws_session_token=get_first_property_value( |
316 | | - properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN, DEPRECATED_SESSION_TOKEN |
317 | | - ), |
| 304 | + aws_access_key_id=get_first_property_value(properties, GLUE_ACCESS_KEY_ID, AWS_ACCESS_KEY_ID), |
| 305 | + aws_secret_access_key=get_first_property_value(properties, GLUE_SECRET_ACCESS_KEY, AWS_SECRET_ACCESS_KEY), |
| 306 | + aws_session_token=get_first_property_value(properties, GLUE_SESSION_TOKEN, AWS_SESSION_TOKEN), |
318 | 307 | ) |
319 | 308 | self.glue: GlueClient = session.client("glue", endpoint_url=properties.get(GLUE_CATALOG_ENDPOINT)) |
320 | 309 |
|
@@ -670,7 +659,7 @@ def drop_namespace(self, namespace: Union[str, Identifier]) -> None: |
670 | 659 | self.glue.delete_database(Name=database_name) |
671 | 660 |
|
672 | 661 | def list_tables(self, namespace: Union[str, Identifier]) -> List[Identifier]: |
673 | | - """List tables under the given namespace in the catalog (including non-Iceberg tables). |
| 662 | + """List Iceberg tables under the given namespace in the catalog. |
674 | 663 |
|
675 | 664 | Args: |
676 | 665 | namespace (str | Identifier): Namespace identifier to search. |
@@ -698,7 +687,7 @@ def list_tables(self, namespace: Union[str, Identifier]) -> List[Identifier]: |
698 | 687 |
|
699 | 688 | except self.glue.exceptions.EntityNotFoundException as e: |
700 | 689 | raise NoSuchNamespaceError(f"Database does not exist: {database_name}") from e |
701 | | - return [(database_name, table["Name"]) for table in table_list] |
| 690 | + return [(database_name, table["Name"]) for table in table_list if self.__is_iceberg_table(table)] |
702 | 691 |
|
703 | 692 | def list_namespaces(self, namespace: Union[str, Identifier] = ()) -> List[Identifier]: |
704 | 693 | """List namespaces from the given namespace. If not given, list top-level namespaces from the catalog. |
@@ -781,3 +770,7 @@ def list_views(self, namespace: Union[str, Identifier]) -> List[Identifier]: |
781 | 770 |
|
782 | 771 | def drop_view(self, identifier: Union[str, Identifier]) -> None: |
783 | 772 | raise NotImplementedError |
| 773 | + |
| 774 | + @staticmethod |
| 775 | + def __is_iceberg_table(table: TableTypeDef) -> bool: |
| 776 | + return table.get("Parameters", {}).get("table_type", "").lower() == ICEBERG |
0 commit comments