Skip to content

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

geruh
Copy link
Contributor

@geruh geruh commented Jun 11, 2025

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:

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.

@geruh geruh changed the title fix: glue drop_namespace checking all tables fix: glue drop_namespace check all table types Jun 11, 2025
@geruh geruh changed the title fix: glue drop_namespace check all table types fix: glue drop_namespace to check non-iceberg tables Jun 11, 2025
Copy link
Contributor

@kevinjqliu kevinjqliu left a 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:
Copy link
Contributor

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

except self.glue.exceptions.EntityNotFoundException as e:
raise NoSuchNamespaceError(f"Database does not exist: {database_name}") from e

@@ -680,13 +680,19 @@ def drop_namespace(self, namespace: Union[str, Identifier]) -> None:
"""
database_name = self.identifier_to_database(namespace, NoSuchNamespaceError)
try:
table_list = self.list_tables(namespace=database_name)
except NoSuchNamespaceError as e:
table_list_response = self.glue.get_tables(DatabaseName=database_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinjqliu kevinjqliu merged commit 47613d3 into apache:main Jun 12, 2025
10 checks passed
@geruh geruh deleted the glue-drop-ns branch June 12, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants