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

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 3912c08915 [pvfs] Set working directory to the catalog root in 
PaimonVirtualFileSystem (#9507)
3912c08915 is described below

commit 3912c089152eacf4eff6a6b6f70072f72c10cc5d
Author: Eunbin Son <[email protected]>
AuthorDate: Wed Sep 2 15:42:52 2026 +0900

    [pvfs] Set working directory to the catalog root in PaimonVirtualFileSystem 
(#9507)
---
 .../paimon/vfs/hadoop/PaimonVirtualFileSystem.java |  4 +++-
 .../paimon/vfs/hadoop/VirtualFileSystemTest.java   | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git 
a/paimon-vfs/paimon-vfs-hadoop/src/main/java/org/apache/paimon/vfs/hadoop/PaimonVirtualFileSystem.java
 
b/paimon-vfs/paimon-vfs-hadoop/src/main/java/org/apache/paimon/vfs/hadoop/PaimonVirtualFileSystem.java
index 356d96f6f0..58d67e1f6d 100644
--- 
a/paimon-vfs/paimon-vfs-hadoop/src/main/java/org/apache/paimon/vfs/hadoop/PaimonVirtualFileSystem.java
+++ 
b/paimon-vfs/paimon-vfs-hadoop/src/main/java/org/apache/paimon/vfs/hadoop/PaimonVirtualFileSystem.java
@@ -67,11 +67,13 @@ public class PaimonVirtualFileSystem extends FileSystem {
         this.conf = conf;
         super.initialize(uri, conf);
 
-        this.workingDirectory = new Path(uri);
         if (uri.getAuthority() == null || uri.getAuthority().isEmpty()) {
             throw new IllegalArgumentException("URI authority is empty: " + 
uri);
         }
         this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority() + 
"/");
+        // Hadoop passes the full user URI here, path component included, so 
the working
+        // directory must be derived from the normalized catalog root.
+        this.workingDirectory = new Path(this.uri);
 
         initVFSOperations();
     }
diff --git 
a/paimon-vfs/paimon-vfs-hadoop/src/test/java/org/apache/paimon/vfs/hadoop/VirtualFileSystemTest.java
 
b/paimon-vfs/paimon-vfs-hadoop/src/test/java/org/apache/paimon/vfs/hadoop/VirtualFileSystemTest.java
index 62c893a52b..01852ec015 100644
--- 
a/paimon-vfs/paimon-vfs-hadoop/src/test/java/org/apache/paimon/vfs/hadoop/VirtualFileSystemTest.java
+++ 
b/paimon-vfs/paimon-vfs-hadoop/src/test/java/org/apache/paimon/vfs/hadoop/VirtualFileSystemTest.java
@@ -473,6 +473,30 @@ public abstract class VirtualFileSystemTest {
                 new Path(vfsPath, "schema").toString(), 
fileStatuses[0].getPath().toString());
     }
 
+    @Test
+    public void testWorkingDirectoryIsCatalogRoot() throws Exception {
+        String databaseName = "test_db";
+        String tableName = "object_table";
+        createObjectTable(databaseName, tableName);
+
+        // Hadoop hands initialize() the full user URI, path component included
+        Path filePath = new Path(vfsRoot, databaseName + "/" + tableName + 
"/a.csv");
+        try (FileSystem fs = new PaimonVirtualFileSystem()) {
+            fs.initialize(filePath.toUri(), vfs.getConf());
+            assertThat(fs.getWorkingDirectory()).isEqualTo(vfsRoot);
+
+            // A relative path resolves against the catalog root, so it lands 
in the table it
+            // names rather than in the table that happened to open this file 
system
+            String relative = databaseName + "/" + tableName + "2/b.csv";
+            FSDataOutputStream out = fs.create(new Path(relative));
+            out.write("hello".getBytes());
+            out.close();
+
+            assertThat(fs.exists(new Path(vfsRoot, relative))).isTrue();
+            assertThat(fs.exists(filePath)).isFalse();
+        }
+    }
+
     @Test
     public void testTrash() throws Exception {
         String databaseName = "test_db";

Reply via email to