Repository navigation
Reject dropping a SqlCatalog namespace that has child namespaces - #4469
gedaliakliger wants to merge 1 commit into
Conversation
drop_namespace only checked for tables, so dropping a parent namespace deleted its properties and reported success while its children kept it listed. Java's JdbcCatalog.dropNamespace throws NamespaceNotEmptyException in this case.
rahulsmahadev
left a comment
There was a problem hiding this comment.
Thanks @gedaliakliger! The new test fails on main ("DID NOT RAISE") and passes here, and checking child namespaces before tables matches Java's JdbcCatalog.dropNamespace. I also tried a sibling that shares a prefix (p and pq), an underscore name (a_b and axb), a grandchild, a table in a sibling, and a child that exists only as properties. Each behaved as expected, and a failed drop leaves the properties alone.
Optional: add a sibling case to the new test. list_namespaces relies on an exact tuple check after a LIKE query, and a later change there could break this without any test noticing. And because this turns a silent no-op into an exception, the answer to "user-facing changes" could ask for the changelog label.
|
Thanks for checking this. |
Rationale for this change
SqlCatalog.drop_namespaceonly checks for tables. With namespacesaanda.b,drop_namespace("a")deletes the properties ofaand returns, whileais still listed and still exists through its child.InMemoryCataloginherits this.Java's
JdbcCatalog.dropNamespacethrowsNamespaceNotEmptyExceptionwhenlistNamespaces(namespace)is not empty. This change does the same and raisesNamespaceNotEmptyError.Are these changes tested?
Yes.
test_drop_namespace_raises_error_when_namespace_has_child_namespacesfails onmain(DID NOT RAISE NamespaceNotEmptyError) and passes with this change. Ran here: the namespace tests intests/catalog/test_catalog_behaviors.py,tests/catalog/test_sql.pyandtests/cli/test_console.py(258 passed), plus ruff, ruff-format and mypy on the changed files. The full suites are left to CI.Are there any user-facing changes?
Yes.
drop_namespaceonSqlCatalogandInMemoryCatalograisesNamespaceNotEmptyErrorfor a namespace that has child namespaces, instead of returning without dropping it.