-
Notifications
You must be signed in to change notification settings - Fork 378
fix: glue drop_namespace to check non-iceberg tables #2083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM this prevents us from dropping a namespace when there are other non-iceberg tables still present
except NoSuchNamespaceError as e: | ||
table_list_response = self.glue.get_tables(DatabaseName=database_name) | ||
table_list = table_list_response["TableList"] | ||
except self.glue.exceptions.EntityNotFoundException as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.glue.exceptions.EntityNotFoundException
mirrors the list_tables
implementation
iceberg-python/pyiceberg/catalog/glue.py
Lines 725 to 726 in 26829ff
except self.glue.exceptions.EntityNotFoundException as e: | |
raise NoSuchNamespaceError(f"Database does not exist: {database_name}") from e |
try: | ||
table_list = self.list_tables(namespace=database_name) | ||
except NoSuchNamespaceError as e: | ||
table_list_response = self.glue.get_tables(DatabaseName=database_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Rationale for this change This PR is adding a check for all tables in the GlueCatalog instead of just iceberg tables. GlueCatalog allows users to store other table formats under the same database. Using the catalog's `list_tables()` call filters out non-Iceberg table types, which avoids the proper Iceberg `NamespaceNotEmptyError` and instead returns a generic Glue SDK error. This change aligns with the behavior in the java implementation: - https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java#L538-L571 # Are these changes tested? Tested locally with Glue Catalog # Are there any user-facing changes? Yes new exception message when a `drop_namespace()` call is made against a database with non-iceberg tables.
# Rationale for this change This PR is adding a check for all tables in the GlueCatalog instead of just iceberg tables. GlueCatalog allows users to store other table formats under the same database. Using the catalog's `list_tables()` call filters out non-Iceberg table types, which avoids the proper Iceberg `NamespaceNotEmptyError` and instead returns a generic Glue SDK error. This change aligns with the behavior in the java implementation: - https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java#L538-L571 # Are these changes tested? Tested locally with Glue Catalog # Are there any user-facing changes? Yes new exception message when a `drop_namespace()` call is made against a database with non-iceberg tables.
Rationale for this change
This PR is adding a check for all tables in the GlueCatalog instead of just iceberg tables.
GlueCatalog allows users to store other table formats under the same database. Using the catalog's
list_tables()
call filters out non-Iceberg table types, which avoids the proper IcebergNamespaceNotEmptyError
and instead returns a generic Glue SDK error.This change aligns with the behavior in the java implementation:
Are these changes tested?
Tested locally with Glue Catalog
Are there any user-facing changes?
Yes new exception message when a
drop_namespace()
call is made against a database with non-iceberg tables.