rdblue commented on code in PR #16174:
URL: https://github.com/apache/iceberg/pull/16174#discussion_r3211545931


##########
core/src/test/java/org/apache/iceberg/util/TestLocationUtil.java:
##########
@@ -84,4 +84,95 @@ void testStripTrailingSlashForRootPathWithTrailingSlashes() {
         .as("Should be root path")
         .isEqualTo(rootPath);
   }
+
+  @Test
+  public void testResolveRelativeLocations() {
+    String tableLocation = "s3://bucket/table";
+
+    assertThat(LocationUtil.resolveLocation(tableLocation, 
"/metadata/file.parquet"))
+        .isEqualTo("s3://bucket/table/metadata/file.parquet");
+
+    assertThat(LocationUtil.resolveLocation(tableLocation, 
"/data/00000-0.parquet"))
+        .isEqualTo("s3://bucket/table/data/00000-0.parquet");
+  }
+
+  @Test
+  public void testResolveLocationsWithColonsInSegments() {
+    String tableLocation = "s3://bucket/table";
+
+    assertThat(
+            LocationUtil.resolveLocation(tableLocation, 
"/data/partition=key:value/file.parquet"))
+        .isEqualTo("s3://bucket/table/data/partition=key:value/file.parquet");
+
+    assertThat(LocationUtil.resolveLocation(tableLocation, 
"/metadata/snap-123:456.avro"))
+        .isEqualTo("s3://bucket/table/metadata/snap-123:456.avro");
+  }
+
+  @Test
+  public void testResolveAbsoluteLocationsUnchanged() {
+    String tableLocation = "s3://bucket/table";
+
+    assertThat(LocationUtil.resolveLocation(tableLocation, 
"s3://other/bucket/file.parquet"))
+        .isEqualTo("s3://other/bucket/file.parquet");
+
+    assertThat(LocationUtil.resolveLocation(tableLocation, 
"hdfs://namenode/path/file.parquet"))
+        .isEqualTo("hdfs://namenode/path/file.parquet");
+  }
+
+  @Test
+  public void testRelativize() {
+    String tableLocation = "s3://bucket/table";
+
+    assertThat(
+            LocationUtil.relativizeLocation(
+                tableLocation, "s3://bucket/table/metadata/file.parquet"))
+        .isEqualTo("/metadata/file.parquet");
+
+    assertThat(
+            LocationUtil.relativizeLocation(
+                tableLocation, "s3://bucket/table/data/00000-0.parquet"))
+        .isEqualTo("/data/00000-0.parquet");
+  }
+
+  @Test
+  public void testRelativizeLocationNotUnderTableLocation() {

Review Comment:
   I'd like for this to test both a table/path mismatch and a bucket mismatch.



-- 
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