Baunsgaard commented on code in PR #15173:
URL: https://github.com/apache/iceberg/pull/15173#discussion_r2746041601


##########
core/src/test/java/org/apache/iceberg/TestRewriteTablePathUtil.java:
##########
@@ -80,4 +81,89 @@ public void testStagingPathWithNoMiddlePart() {
         RewriteTablePathUtil.stagingPath(fileDirectlyUnderPrefix, 
sourcePrefix, stagingDir);
     assertThat(newMethodResult).isEqualTo("/staging/file.parquet");
   }
+
+  @Test
+  public void testRelativizePathUnderPrefix() {
+    // Normal case: path is under prefix
+    assertThat(RewriteTablePathUtil.relativize("/a/b/c", 
"/a")).isEqualTo("b/c");
+    assertThat(RewriteTablePathUtil.relativize("/a/b", "/a")).isEqualTo("b");
+    
assertThat(RewriteTablePathUtil.relativize("/source/table/data/file.parquet", 
"/source/table"))
+        .isEqualTo("data/file.parquet");
+  }
+
+  @Test
+  public void testRelativizePathEqualsPrefix() {
+    // Edge case: path equals prefix exactly (issue #15172)
+    assertThat(RewriteTablePathUtil.relativize("/a", "/a")).isEqualTo("");
+    assertThat(RewriteTablePathUtil.relativize("/source/table", 
"/source/table")).isEqualTo("");
+    assertThat(RewriteTablePathUtil.relativize("s3://bucket/warehouse", 
"s3://bucket/warehouse"))
+        .isEqualTo("");
+  }
+
+  @Test
+  public void testRelativizePathEqualsPrefixWithTrailingSeparator() {
+    // Edge case: path equals prefix with trailing separator on path
+    assertThat(RewriteTablePathUtil.relativize("/a/", "/a")).isEqualTo("");
+    assertThat(RewriteTablePathUtil.relativize("/source/table/", 
"/source/table")).isEqualTo("");
+
+    // Edge case: prefix has trailing separator
+    assertThat(RewriteTablePathUtil.relativize("/a", "/a/")).isEqualTo("");

Review Comment:
   You're right! Instead of removing the test case, I've kept it as a negative 
test that asserts it throws the exception.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to