Skip to content

IcebergCatalog- updateNamespaceProperties on single commit#4013

Open
rambleraptor wants to merge 2 commits intoapache:mainfrom
rambleraptor:polaris-commit-fix
Open

IcebergCatalog- updateNamespaceProperties on single commit#4013
rambleraptor wants to merge 2 commits intoapache:mainfrom
rambleraptor:polaris-commit-fix

Conversation

@rambleraptor
Copy link

@rambleraptor rambleraptor commented Mar 17, 2026

First time Polaris contributor here! I've been working mostly on the Iceberg side.

We ran the PyIceberg Catalog Tests against Polaris (apache/iceberg-python#3106) and discovered that Polaris can't handle adding / removing namespace properties at the same time.

This is because Polaris attempts to handle this as two commits (which run into concurrency issues), when the Iceberg spec supports a single commit.

This PR adds support for creating this single commit for Iceberg Catalogs.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

public boolean updateProperties(
Namespace namespace, Set<String> removals, Map<String, String> updates)
throws NoSuchNamespaceException {
PolarisResolvedPathWrapper resolvedEntities = resolvedEntityView.getResolvedPath(namespace);
Copy link
Member

Choose a reason for hiding this comment

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

Why not using resolvedEntityView.getResolvedPath(ResolvedPathKey.ofNamespace(namespace)); like in other methods here ?

if (!updates.isEmpty()) {
catalog.setProperties(namespace, updates);
}
if (catalog instanceof IcebergCatalog polarisCatalog) {
Copy link
Member

Choose a reason for hiding this comment

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

Due to that we have a direct dependency with IcebergCatalog.
As CatalogHandlerUtils implements the SupportNamespace, it should not be "linked" to any catalog specific implementation.

I think it should be cleaner to isolate this in a specific method (for clarity).

catalog.setProperties(namespace, updates);
}
if (catalog instanceof IcebergCatalog polarisCatalog) {
polarisCatalog.updateProperties(namespace, removals, updates);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think if both updates and removals are empty, there's no need to call updateProperties no?

* @param updates the map of properties to update
* @return true if the properties were updated, false otherwise
*/
public boolean updateProperties(
Copy link
Contributor

Choose a reason for hiding this comment

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

The returned boolean is never used / checked.

Comment on lines +764 to +776
if (!realmConfig.getConfig(FeatureConfiguration.ALLOW_NAMESPACE_LOCATION_OVERLAP)) {
LOGGER.debug("Validating no overlap with sibling tables or namespaces");
validateNoLocationOverlap(
NamespaceEntity.of(updatedEntity), resolvedEntities.getRawParentPath());
} else {
LOGGER.debug("Skipping location overlap validation for namespace '{}'", namespace);
}
if (!realmConfig.getConfig(
BehaviorChangeConfiguration.ALLOW_NAMESPACE_CUSTOM_LOCATION, catalogEntity)) {
if (updates.containsKey(PolarisEntityConstants.ENTITY_BASE_LOCATION)) {
validateNamespaceLocation(NamespaceEntity.of(entity), resolvedEntities);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These checks appear twice, can we extract a common utility method?


catalog.updateProperties(
NS,
ImmutableSet.of("prop1", "prop2", "missing_prop"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's keep one old prop to assert that it is preserved after the update:

Suggested change
ImmutableSet.of("prop1", "prop2", "missing_prop"),
ImmutableSet.of("prop1", "missing_prop"),

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.

4 participants