Skip to content

Fix nosql namespace / table name clash#4148

Merged
dimas-b merged 5 commits intoapache:mainfrom
Subham-KRLX:fix/nosql-namespace-table-clash-4108
Apr 13, 2026
Merged

Fix nosql namespace / table name clash#4148
dimas-b merged 5 commits intoapache:mainfrom
Subham-KRLX:fix/nosql-namespace-table-clash-4108

Conversation

@Subham-KRLX
Copy link
Copy Markdown
Contributor

@Subham-KRLX Subham-KRLX commented Apr 8, 2026

Resolves test-crashing IllegalArgumentException errors in NoSQL persistence when creating a table that clashes with an existing namespace name.

Changes:

  • Added a proactive persistence-neutral clash check to IcebergCatalogHandler allowing for user-friendly AlreadyExistsException messages.
  • Added a robustness fix to MutationAttempt.java to prevent the NoSQL metastore from crashing during mapToObj processing.
  • Added reproduction test testNamespaceTableClash.

Fixes #4108

Checklist

@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Apr 8, 2026
@Subham-KRLX Subham-KRLX force-pushed the fix/nosql-namespace-table-clash-4108 branch 2 times, most recently from ca3e04a to 0cb1f42 Compare April 8, 2026 17:27
Subham-KRLX added a commit to Subham-KRLX/polaris that referenced this pull request Apr 8, 2026
- Added missing closing brace in fallbackToFullLoadTable method
- Fixed authorizeLoadTable call to use boolean instead of EnumSet
- Added @SuppressWarnings for Error Prone FormatStringAnnotation
- Updated error message formatting to be compile-safe
@Subham-KRLX
Copy link
Copy Markdown
Contributor Author

@dimas-b Fixed the NoSQL table/namespace name clash by adding a pre-check that returns a clear AlreadyExistsException instead of the obscure metastore crash plus a small NoSQL robustness fix and a regression test for the clash case.

Copy link
Copy Markdown
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix, @Subham-KRLX !

var existingTypeId = existingRef.type();
var expectedTypeId = objTypeForPolarisType(entityType, entity.getSubType()).id();

if (existingTypeId.equals(expectedTypeId)) {
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.

Nice find! I think this fix is sufficient. Changes in IcebergCatalogHandler are probably not necessary. WDYT?

Copy link
Copy Markdown
Contributor

@dimas-b dimas-b Apr 8, 2026

Choose a reason for hiding this comment

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

Could you add a test for NS / Table name collision to PolarisRestCatalogIntegrationBase?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yea - this should be the right place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This case is NoSQL-specific The shared test would fail on file-backed catalogs so I am opting in only from the NoSQL integration test that reproduces the issue.

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.

Fair enough. Let's keep the fix narrow and specific to the issue 👍

@Subham-KRLX Subham-KRLX force-pushed the fix/nosql-namespace-table-clash-4108 branch from 3b5d8b4 to 20f0fb4 Compare April 9, 2026 03:28
return externalCatalogBaseLocation;
}

protected boolean testNamespaceTableNameCollision() {
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.

Why wouldn't we test this for all subclasses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This case only reproduces on the NoSQL backend. Running it across all subclasses fails for file-backed catalogs, so I kept the shared test and enable it only where the bug is actually reproducible.

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.

Sure, but the test is valid regardless of the backend. (We could also add tests for other clashes: view vs ns, view vs table – this one maybe exists already).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tested this across all subclasses and file-backed currently behaves differently, so I kept this PR scoped to the NoSQL regression in #4108. I’ll follow up with a separate PR to unify clash behavior across backends and add the extra clash tests.

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.

How about we remove this test from current PR completely and re-add it in a new PR with persistence-neutral fixes?

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.

Tests added to TestNoSqlMetaStoreManager appear to be sufficient for the current production code change and the use case from #4108.

Extending to other backends makes sense though, yet it might be best done in a dedicated PR 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have just updated the PR to completely remove the shared integration test keeping the scope narrow and strictly focused on the NoSQL regression fix as the tests in TestNoSqlMetaStoreManager are sufficient for this specific issue. I will follow up with a dedicated PR to handle the persistence neutral fixes properly and comprehensively add these collision tests across all backends as suggested.

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.

Thx, @Subham-KRLX ! I opened #4168 for followup.

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.

@Subham-KRLX : Do you feel like working on #4168 ?.. Just checking 😉

authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));
TableIdentifier identifier = TableIdentifier.of(namespace, request.name());
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier);
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.

This change looks unnecessary now 🤔

*/
public ImmutableLoadCredentialsResponse loadCredentials(
TableIdentifier tableIdentifier, Optional<String> refreshCredentialsEndpoint) {

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.

nit: unnecessary change

authorizeCreateTableLikeUnderNamespaceOperationOrThrow(
op, TableIdentifier.of(namespace, request.name()));
TableIdentifier identifier = TableIdentifier.of(namespace, request.name());
authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier);
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.

This change looks unnecessary now 🤔

import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableCommit;
import org.apache.iceberg.catalog.TableIdentifier;

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.

Still some unnecessary changes in this file.

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.

+1

@Subham-KRLX : please also fix spotless checks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed spotless for this PR and pushed the update.

@QuarkusIntegrationTest
@TestProfile(value = NoSqlCatalogIT.Profile.class)
public class NoSqlCatalogIT extends PolarisRestCatalogRustFSIT {

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.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed the unnecessary change in NoSqlCatalogIT.java and kept only the spotless-required formatting updates in this PR.I removed the unnecessary change in NoSqlCatalogIT.java and kept only the spotless-required formatting updates in this PR.

Copy link
Copy Markdown
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Thanks, @Subham-KRLX ! Let's give some more time for @adutra to catch up with recent changes, and I hope we can merge on Mon.

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Apr 10, 2026
@dimas-b dimas-b changed the title Fix/nosql namespace table clash 4108 Fix nosql namespace / table name clash Apr 10, 2026
@dimas-b dimas-b merged commit 648c8ee into apache:main Apr 13, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Apr 13, 2026
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.

Obscure error message on table name clash with a namespace in NoSQL Persistence

4 participants