Skip to content

Keep a SQL catalog namespace after removing its last property - #4503

Open
gedaliakliger wants to merge 1 commit into
apache:mainfrom
gedaliakliger:fix/sql-keep-namespace-without-properties
Open

gedaliakliger wants to merge 1 commit into
apache:mainfrom
gedaliakliger:fix/sql-keep-namespace-without-properties

Conversation

@gedaliakliger

Copy link
Copy Markdown
Contributor

Rationale for this change

SqlCatalog.create_namespace writes the reserved exists property only when no user properties are supplied. Removing every property from such a namespace deleted its only row from iceberg_namespace_properties, so namespace_exists returned false and the namespace vanished from list_namespaces. Java's JdbcCatalog.createNamespace always stores exists=true alongside user properties, and JdbcUtil.namespaceExists relies on those rows. When removals leave no properties, store the minimal exists row again.

Are these changes tested?

test_update_namespace_properties_removes_all_properties in tests/catalog/test_catalog_behaviors.py removes the only property and asserts the namespace still exists, is listed, and loads with {"exists": "true"}. It fails on main (9 cases, assert False on namespace_exists) and passes with this change (9 cases).

Ran here: .venv/bin/python -m pytest tests/catalog/test_catalog_behaviors.py -m unit -k update_namespace_properties_removes_all_properties -v, .venv/bin/prek run ruff ruff-format --files pyiceberg/catalog/sql.py tests/catalog/test_catalog_behaviors.py, .venv/bin/prek run mypy --files pyiceberg/catalog/sql.py tests/catalog/test_catalog_behaviors.py. CI runs the full suite.

Are there any user-facing changes?

Yes. Removing all properties from a SQL catalog namespace no longer makes the namespace disappear; it stays listed and reports {"exists": "true"}.

A namespace without tables exists only through its rows in
iceberg_namespace_properties, so update_namespace_properties with
removals covering every property made the namespace disappear.
Store the minimal `exists` property again when the last one is removed.

This branch has not been deployed

No deployments
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.

1 participant