You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "harshitaajoshi (via GitHub)" <gi...@apache.org> on 2026/08/02 21:18:16 UTC

[PR] Add dedicated JDBC regression tests for hasOverlappingSiblings overlap detection [polaris]

harshitaajoshi opened a new pull request, #5221:
URL: https://github.com/apache/polaris/pull/5221

   ## What
   
   Adds comprehensive regression test coverage for `hasOverlappingSiblings` in the JDBC persistence layer, as requested in #4600. Also adds a concrete H2-based parameterized test runner so these tests can run locally without Docker.
   
   ## Why
   
   The existing JDBC test only covered a basic parent/child overlap and a non-overlapping case. The NoSQL layer had much broader coverage for edge cases (trailing slashes, both overlap directions, duplicates, entity drops) but the JDBC layer did not. These regression tests ensure the JDBC overlap detection behaves correctly across all important scenarios and prevents future regressions.
   
   Fixes #4600
   
   ## Changes
   
   - Added 4 new test methods to `AtomicMetastoreManagerWithJdbcBasePersistenceImplTest`:
     - `testHasOverlappingSiblingsTrailingSlashVariants`: verifies that a location without a trailing slash still overlaps with a stored location that has one
     - `testHasOverlappingSiblingsParentChildBothDirections`: verifies overlap is detected when the candidate is a child of an existing entity AND when it is a parent of an existing entity
     - `testHasOverlappingSiblingsDuplicateLocations`: verifies that an exact duplicate base location is reported as overlapping
     - `testHasOverlappingSiblingsAfterEntityDrop`: verifies overlap persists while duplicates remain, and disappears only after all overlapping entities are dropped
   - Added a `createOverlapTestCatalog` helper to reduce boilerplate across new tests
   - Created `AtomicMetastoreManagerWithJdbcBasePersistenceImplH2SchemaTest` as a concrete H2 parameterized test runner (mirrors the Postgres IT pattern but runs without Docker)
   
   ## Checklist
   - [x] Don't disclose security issues! (contact security@apache.org)
   - [x] Clearly explained why the changes are needed, or linked related issues: Fixes #4600
   - [x] Added/updated tests with good coverage (and explained how)
   - [x] Added comments for complex logic
   - [ ] Updated `CHANGELOG.md` (if needed)
   - [ ] Updated documentation in `site/content/in-dev/unreleased` (if needed)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add dedicated JDBC regression tests for hasOverlappingSiblings overlap detection [polaris]

Posted by "flyingImer (via GitHub)" <gi...@apache.org>.
flyingImer commented on code in PR #5221:
URL: https://github.com/apache/polaris/pull/5221#discussion_r3961248450


##########
persistence/relational-jdbc/src/test/java/org/apache/polaris/persistence/relational/jdbc/AtomicMetastoreManagerWithJdbcBasePersistenceImplTest.java:
##########
@@ -158,6 +159,205 @@ void testHasOverlappingSiblingsUsesStoredBaseLocation() {
         .contains(Optional.empty());
   }
 
+  @Test
+  void testHasOverlappingSiblingsTrailingSlashVariants() {
+    Assumptions.assumeThat(schemaVersion()).isGreaterThanOrEqualTo(2);
+
+    var metaStoreManager = polarisTestMetaStoreManager.polarisMetaStoreManager();
+    var callContext = polarisTestMetaStoreManager.polarisCallContext();
+    PolarisBaseEntity catalog = createOverlapTestCatalog(metaStoreManager, callContext, "slash");
+
+    PolarisBaseEntity nsWithSlash =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "ns_slash",
+            "s3://bucket/foo/bar/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), nsWithSlash);
+
+    // Candidate without trailing slash should still detect overlap
+    TestLocationBasedEntity candidateNoSlash =
+        new TestLocationBasedEntity(
+            buildLocationBasedNamespace(
+                catalog,
+                metaStoreManager.generateNewEntityId(callContext).getId(),
+                "candidate_no_slash",
+                "s3://bucket/foo/bar"));
+
+    Assertions.assertThat(metaStoreManager.hasOverlappingSiblings(callContext, candidateNoSlash))
+        .as("Location without trailing slash must overlap with stored trailing-slash location")
+        .isPresent()
+        .contains(Optional.of("s3://bucket/foo/bar/"));
+  }
+
+  @Test
+  void testHasOverlappingSiblingsParentChildBothDirections() {
+    Assumptions.assumeThat(schemaVersion()).isGreaterThanOrEqualTo(2);
+
+    var metaStoreManager = polarisTestMetaStoreManager.polarisMetaStoreManager();
+    var callContext = polarisTestMetaStoreManager.polarisCallContext();
+    PolarisBaseEntity catalog =
+        createOverlapTestCatalog(metaStoreManager, callContext, "parent_child");
+
+    PolarisBaseEntity parentNs =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "parent_ns",
+            "s3://bucket/data/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), parentNs);
+
+    // Child of existing parent must report overlap
+    TestLocationBasedEntity childCandidate =
+        new TestLocationBasedEntity(
+            buildLocationBasedNamespace(
+                catalog,
+                metaStoreManager.generateNewEntityId(callContext).getId(),
+                "child_candidate",
+                "s3://bucket/data/nested/deep/"));
+
+    Assertions.assertThat(metaStoreManager.hasOverlappingSiblings(callContext, childCandidate))
+        .as("Child location must detect parent overlap")
+        .isPresent()
+        .contains(Optional.of("s3://bucket/data/"));
+
+    // Now add a deeply nested entity and verify a broader parent candidate detects it
+    PolarisBaseEntity deepNs =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "deep_ns",
+            "s3://bucket/warehouse/a/b/c/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), deepNs);
+
+    TestLocationBasedEntity parentCandidate =
+        new TestLocationBasedEntity(
+            buildLocationBasedNamespace(
+                catalog,
+                metaStoreManager.generateNewEntityId(callContext).getId(),
+                "parent_candidate",
+                "s3://bucket/warehouse/a/"));
+
+    Assertions.assertThat(metaStoreManager.hasOverlappingSiblings(callContext, parentCandidate))
+        .as("Parent location must detect existing child overlap")
+        .isPresent()
+        .contains(Optional.of("s3://bucket/warehouse/a/b/c/"));
+  }
+
+  @Test
+  void testHasOverlappingSiblingsDuplicateLocations() {
+    Assumptions.assumeThat(schemaVersion()).isGreaterThanOrEqualTo(2);
+
+    var metaStoreManager = polarisTestMetaStoreManager.polarisMetaStoreManager();
+    var callContext = polarisTestMetaStoreManager.polarisCallContext();
+    PolarisBaseEntity catalog =
+        createOverlapTestCatalog(metaStoreManager, callContext, "duplicate");
+
+    PolarisBaseEntity ns1 =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "dup1",
+            "s3://bucket/shared/path/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), ns1);
+
+    PolarisBaseEntity ns2 =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "dup2",
+            "s3://bucket/shared/path/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), ns2);
+
+    // A candidate with the same location must detect the overlap
+    TestLocationBasedEntity sameLocationCandidate =
+        new TestLocationBasedEntity(
+            buildLocationBasedNamespace(
+                catalog,
+                metaStoreManager.generateNewEntityId(callContext).getId(),
+                "same_loc",
+                "s3://bucket/shared/path/"));
+
+    Assertions.assertThat(
+            metaStoreManager.hasOverlappingSiblings(callContext, sameLocationCandidate))
+        .as("Exact duplicate location must report overlap")
+        .isPresent()
+        .contains(Optional.of("s3://bucket/shared/path/"));
+  }
+
+  @Test
+  void testHasOverlappingSiblingsAfterEntityDrop() {
+    Assumptions.assumeThat(schemaVersion()).isGreaterThanOrEqualTo(2);
+
+    var metaStoreManager = polarisTestMetaStoreManager.polarisMetaStoreManager();
+    var callContext = polarisTestMetaStoreManager.polarisCallContext();
+    PolarisBaseEntity catalog = createOverlapTestCatalog(metaStoreManager, callContext, "drop");
+
+    PolarisBaseEntity ns1 =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "drop_ns1",
+            "s3://bucket/drop/path/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), ns1);
+
+    PolarisBaseEntity ns2 =
+        buildLocationBasedNamespace(
+            catalog,
+            metaStoreManager.generateNewEntityId(callContext).getId(),
+            "drop_ns2",
+            "s3://bucket/drop/path/");
+    metaStoreManager.createEntityIfNotExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), ns2);
+
+    // Drop the first entity
+    metaStoreManager.dropEntityIfExists(
+        callContext, List.of(PolarisEntity.toCore(catalog)), ns1, null, false);

Review Comment:
   Could we assert that both drops succeed? If a regression caused the second write at this location to replace ns1, the first drop would return ENTITY_NOT_FOUND, but both overlap assertions would still pass with only ns2 present initially. Checking the drop results would make this test catch that regression as well.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add dedicated JDBC regression tests for hasOverlappingSiblings overlap detection [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5221:
URL: https://github.com/apache/polaris/pull/5221#issuecomment-5503107760

   This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add dedicated JDBC regression tests for hasOverlappingSiblings overlap detection [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #5221: Add dedicated JDBC regression tests for hasOverlappingSiblings overlap detection
URL: https://github.com/apache/polaris/pull/5221


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org