Fix nosql namespace / table name clash#4148
Conversation
ca3e04a to
0cb1f42
Compare
- 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
|
@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. |
dimas-b
left a comment
There was a problem hiding this comment.
Thanks for the quick fix, @Subham-KRLX !
| var existingTypeId = existingRef.type(); | ||
| var expectedTypeId = objTypeForPolarisType(entityType, entity.getSubType()).id(); | ||
|
|
||
| if (existingTypeId.equals(expectedTypeId)) { |
There was a problem hiding this comment.
Nice find! I think this fix is sufficient. Changes in IcebergCatalogHandler are probably not necessary. WDYT?
There was a problem hiding this comment.
Could you add a test for NS / Table name collision to PolarisRestCatalogIntegrationBase?
There was a problem hiding this comment.
Yea - this should be the right place.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Fair enough. Let's keep the fix narrow and specific to the issue 👍
3b5d8b4 to
20f0fb4
Compare
| return externalCatalogBaseLocation; | ||
| } | ||
|
|
||
| protected boolean testNamespaceTableNameCollision() { |
There was a problem hiding this comment.
Why wouldn't we test this for all subclasses?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
How about we remove this test from current PR completely and re-add it in a new PR with persistence-neutral fixes?
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thx, @Subham-KRLX ! I opened #4168 for followup.
There was a problem hiding this comment.
@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); |
There was a problem hiding this comment.
This change looks unnecessary now 🤔
| */ | ||
| public ImmutableLoadCredentialsResponse loadCredentials( | ||
| TableIdentifier tableIdentifier, Optional<String> refreshCredentialsEndpoint) { | ||
|
|
| authorizeCreateTableLikeUnderNamespaceOperationOrThrow( | ||
| op, TableIdentifier.of(namespace, request.name())); | ||
| TableIdentifier identifier = TableIdentifier.of(namespace, request.name()); | ||
| authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier); |
There was a problem hiding this comment.
This change looks unnecessary now 🤔
…tests to focus on NoSQL fix
| import org.apache.iceberg.catalog.Namespace; | ||
| import org.apache.iceberg.catalog.TableCommit; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
|
|
There was a problem hiding this comment.
Still some unnecessary changes in this file.
There was a problem hiding this comment.
+1
@Subham-KRLX : please also fix spotless checks
There was a problem hiding this comment.
I fixed spotless for this PR and pushed the update.
| @QuarkusIntegrationTest | ||
| @TestProfile(value = NoSqlCatalogIT.Profile.class) | ||
| public class NoSqlCatalogIT extends PolarisRestCatalogRustFSIT { | ||
|
|
There was a problem hiding this comment.
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.
dimas-b
left a comment
There was a problem hiding this comment.
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.
Resolves test-crashing
IllegalArgumentExceptionerrors in NoSQL persistence when creating a table that clashes with an existing namespace name.Changes:
IcebergCatalogHandlerallowing for user-friendlyAlreadyExistsExceptionmessages.MutationAttempt.javato prevent the NoSQL metastore from crashing duringmapToObjprocessing.testNamespaceTableClash.Fixes #4108
Checklist