This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 03566894524 branch-4.1: [fix](iceberg) Use object store path for data 
location #64028 (#64042)
03566894524 is described below

commit 0356689452456d9aaae4fa08b8ff157ab70dfdb2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jun 3 14:01:30 2026 +0800

    branch-4.1: [fix](iceberg) Use object store path for data location #64028 
(#64042)
    
    Cherry-picked from #64028
    
    Co-authored-by: Gabriel <[email protected]>
---
 .../doris/datasource/iceberg/IcebergUtils.java     |  8 +++-
 .../doris/datasource/iceberg/IcebergUtilsTest.java | 43 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
index 42ad91b2086..bd8680d1321 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergUtils.java
@@ -1136,9 +1136,13 @@ public class IcebergUtils {
         }
         String dataLocation = 
properties.get(TableProperties.WRITE_DATA_LOCATION);
         if (dataLocation == null) {
-            dataLocation = 
properties.get(TableProperties.WRITE_FOLDER_STORAGE_LOCATION);
+            dataLocation = 
Boolean.parseBoolean(properties.get(TableProperties.OBJECT_STORE_ENABLED))
+                    ? properties.get(TableProperties.OBJECT_STORE_PATH) : null;
             if (dataLocation == null) {
-                dataLocation = String.format("%s/data", 
LocationUtil.stripTrailingSlash(table.location()));
+                dataLocation = 
properties.get(TableProperties.WRITE_FOLDER_STORAGE_LOCATION);
+                if (dataLocation == null) {
+                    dataLocation = String.format("%s/data", 
LocationUtil.stripTrailingSlash(table.location()));
+                }
             }
         }
         return dataLocation;
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergUtilsTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergUtilsTest.java
index 1fcde27aa95..49b05f3c1bb 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergUtilsTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/iceberg/IcebergUtilsTest.java
@@ -37,6 +37,7 @@ import org.apache.iceberg.Schema;
 import org.apache.iceberg.Snapshot;
 import org.apache.iceberg.SnapshotRef;
 import org.apache.iceberg.Table;
+import org.apache.iceberg.TableProperties;
 import org.apache.iceberg.expressions.Expression;
 import org.apache.iceberg.expressions.Expressions;
 import org.apache.iceberg.expressions.UnboundPredicate;
@@ -106,6 +107,48 @@ public class IcebergUtilsTest {
         return declaredField.getBoolean(hiveCatalog);
     }
 
+    @Test
+    public void testDataLocationUsesLegacyObjectStorePath() {
+        Table table = Mockito.mock(Table.class);
+        Mockito.when(table.properties()).thenReturn(ImmutableMap.of(
+                TableProperties.OBJECT_STORE_ENABLED, "true",
+                TableProperties.OBJECT_STORE_PATH, 
"s3://bucket/legacy-object-store",
+                TableProperties.WRITE_FOLDER_STORAGE_LOCATION, 
"s3://bucket/folder-storage"));
+
+        Assert.assertEquals("s3://bucket/legacy-object-store", 
IcebergUtils.dataLocation(table));
+    }
+
+    @Test
+    public void 
testDataLocationPrefersWriteDataPathOverLegacyObjectStorePath() {
+        Table table = Mockito.mock(Table.class);
+        Mockito.when(table.properties()).thenReturn(ImmutableMap.of(
+                TableProperties.WRITE_DATA_LOCATION, "s3://bucket/data-path",
+                TableProperties.OBJECT_STORE_PATH, 
"s3://bucket/legacy-object-store"));
+
+        Assert.assertEquals("s3://bucket/data-path", 
IcebergUtils.dataLocation(table));
+    }
+
+    @Test
+    public void 
testDataLocationIgnoresObjectStorePathWhenObjectStoreDisabled() {
+        Table table = Mockito.mock(Table.class);
+        Mockito.when(table.properties()).thenReturn(ImmutableMap.of(
+                TableProperties.OBJECT_STORE_ENABLED, "false",
+                TableProperties.OBJECT_STORE_PATH, 
"s3://bucket/legacy-object-store",
+                TableProperties.WRITE_FOLDER_STORAGE_LOCATION, 
"s3://bucket/folder-storage"));
+
+        Assert.assertEquals("s3://bucket/folder-storage", 
IcebergUtils.dataLocation(table));
+    }
+
+    @Test
+    public void testDataLocationIgnoresObjectStorePathWhenObjectStoreUnset() {
+        Table table = Mockito.mock(Table.class);
+        Mockito.when(table.properties()).thenReturn(ImmutableMap.of(
+                TableProperties.OBJECT_STORE_PATH, 
"s3://bucket/legacy-object-store",
+                TableProperties.WRITE_FOLDER_STORAGE_LOCATION, 
"s3://bucket/folder-storage"));
+
+        Assert.assertEquals("s3://bucket/folder-storage", 
IcebergUtils.dataLocation(table));
+    }
+
     @Test
     public void testIsIcebergRowLineageColumn() {
         Column rowIdColumn = new Column(IcebergUtils.ICEBERG_ROW_ID_COL, 
Type.BIGINT, true);


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

Reply via email to