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 1bb1a14999 [python] Fix Python test errors for 3.6
1bb1a14999 is described below
commit 1bb1a14999c738f86d81e0c03e21d1862ce5c5e6
Author: JingsongLi <[email protected]>
AuthorDate: Mon May 25 12:04:35 2026 +0800
[python] Fix Python test errors for 3.6
---
paimon-python/pypaimon/filesystem/pyarrow_file_io.py | 15 +++++++++++----
paimon-python/pypaimon/tests/file_io_test.py | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/paimon-python/pypaimon/filesystem/pyarrow_file_io.py
b/paimon-python/pypaimon/filesystem/pyarrow_file_io.py
index 4ee75f464d..e7315f3eff 100644
--- a/paimon-python/pypaimon/filesystem/pyarrow_file_io.py
+++ b/paimon-python/pypaimon/filesystem/pyarrow_file_io.py
@@ -304,6 +304,12 @@ class PyArrowFileIO(FileIO):
)
def _initialize_gcs_fs(self) -> FileSystem:
+ if not hasattr(pafs, 'GcsFileSystem'):
+ raise ImportError(
+ "GCS filesystem support requires PyArrow built with GCS
support. "
+ "Please upgrade PyArrow or install a version with GCS enabled."
+ )
+
access_token = self._get_property("gcs.access-token")
token_expiry = self._get_property("gcs.access-token.expiration")
project_id = self._get_property("gcs.project-id")
@@ -319,8 +325,6 @@ class PyArrowFileIO(FileIO):
if project_id:
kwargs["project_id"] = project_id
- # With no kwargs, GcsFileSystem uses ADC automatically
- # (GOOGLE_APPLICATION_CREDENTIALS or GCP metadata server / Workload
Identity)
return pafs.GcsFileSystem(**kwargs)
@staticmethod
@@ -728,8 +732,11 @@ class PyArrowFileIO(FileIO):
else:
return str(path)
- from pyarrow.fs import GcsFileSystem
- if isinstance(self.filesystem, GcsFileSystem):
+ try:
+ from pyarrow.fs import GcsFileSystem
+ except ImportError:
+ GcsFileSystem = None
+ if GcsFileSystem is not None and isinstance(self.filesystem,
GcsFileSystem):
if parsed.scheme and parsed.netloc:
path_part = normalized_path.lstrip('/')
return f"{parsed.netloc}/{path_part}" if path_part else
parsed.netloc
diff --git a/paimon-python/pypaimon/tests/file_io_test.py
b/paimon-python/pypaimon/tests/file_io_test.py
index 2ca5dc6ec7..a9489cfd98 100644
--- a/paimon-python/pypaimon/tests/file_io_test.py
+++ b/paimon-python/pypaimon/tests/file_io_test.py
@@ -562,6 +562,7 @@ class HdfsFileIOTest(unittest.TestCase):
self.assertIn('HADOOP_CONF_DIR', str(ctx.exception))
[email protected](hasattr(pafs, 'GcsFileSystem'), "PyArrow GCS support not
available")
class GCSFileIOPathTest(unittest.TestCase):
"""Unit tests for PyArrowFileIO.to_filesystem_path with GCS (no
credentials required)."""