Skip to content

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

Merged
Fokko merged 1 commit into
apache:mainfrom
gedaliakliger:fix/sql-keep-namespace-without-properties
Nov 30, 2026
Merged

Fokko merged 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.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @gedaliakliger, this looks good. Nice catch, and I like that it also repairs namespaces that older versions created with properties.

One note on the description: Java's JdbcCatalog doesn't re-insert the exists row on removal. It always writes exists=true in createNamespace, hides it in loadNamespaceMetadata, and rejects it in setProperties. So this avoids the same problem in a different way. I've opened #4525 to bring SqlCatalog in line with Java on those points.

@Fokko
Fokko added this pull request to the merge queue Nov 30, 2026
Merged via the queue into apache:main with commit 044af24 Nov 30, 2026
20 checks passed
@gedaliakliger
gedaliakliger deleted the fix/sql-keep-namespace-without-properties branch November 30, 2026 11: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