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 75f0ec6b33 [python] Skip non-tag files when listing tags (#11026)
75f0ec6b33 is described below
commit 75f0ec6b33ef49a102c97a6ca72752c40c827174
Author: YangJie <[email protected]>
AuthorDate: Tue Nov 10 04:14:45 2026 -0500
[python] Skip non-tag files when listing tags (#11026)
---
paimon-python/pypaimon/tag/tag_manager.py | 9 ++++--
.../pypaimon/tests/filesystem_catalog_tag_test.py | 33 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/paimon-python/pypaimon/tag/tag_manager.py
b/paimon-python/pypaimon/tag/tag_manager.py
index 96f4eead8e..9c328f0bf7 100644
--- a/paimon-python/pypaimon/tag/tag_manager.py
+++ b/paimon-python/pypaimon/tag/tag_manager.py
@@ -158,9 +158,12 @@ class TagManager:
tag_file_name = os.path.basename(tag_file)
except TypeError:
tag_file_name = None
- if tag_file_name is not None:
- _, tag = tag_file_name.split("-", 1)
- result.append(tag)
+ # Like the Java TagManager, skip files without the tag prefix,
+ # such as .DS_Store.
+ if not (tag_file_name or '').startswith(TAG_PREFIX):
+ continue
+ _, tag = tag_file_name.split("-", 1)
+ result.append(tag)
return result
def _create_or_replace_tag(
diff --git a/paimon-python/pypaimon/tests/filesystem_catalog_tag_test.py
b/paimon-python/pypaimon/tests/filesystem_catalog_tag_test.py
index e7dc0419cd..a08f9d9042 100644
--- a/paimon-python/pypaimon/tests/filesystem_catalog_tag_test.py
+++ b/paimon-python/pypaimon/tests/filesystem_catalog_tag_test.py
@@ -76,6 +76,39 @@ class FileSystemCatalogTagCRUDTest(unittest.TestCase):
# -- create + get --------------------------------------------------------
+ def test_list_tags_skips_stray_files(self):
+ # macOS Finder writes .DS_Store into a directory it has shown.
+ self.catalog.create_tag(self.identifier, "t1")
+ table = self.catalog.get_table(self.identifier)
+ tag_dir = table.tag_manager().tag_directory()
+ with open(os.path.join(tag_dir, ".DS_Store"), "w") as f:
+ f.write("junk")
+ self.assertEqual(["t1"], table.tag_manager().list_tags())
+
+ def test_rollback_with_stray_file_in_tag_directory(self):
+ # Rollback deletes the newer snapshots and then lists the tags to
+ # delete the newer ones, so a stray file must not stop it half-way.
+ self.catalog.create_tag(self.identifier, "t1")
+ table = self.catalog.get_table(self.identifier)
+ wb = table.new_batch_write_builder()
+ w = wb.new_write()
+ w.write_arrow(pa.Table.from_pydict(
+ {"id": [4], "value": ["d"]}, schema=self.pa_schema))
+ wb.new_commit().commit(w.prepare_commit())
+ w.close()
+ self.catalog.create_tag(self.identifier, "t2")
+ with open(os.path.join(table.tag_manager().tag_directory(),
".DS_Store"), "w") as f:
+ f.write("junk")
+
+ table.rollback_to("t1")
+
+ table = self.catalog.get_table(self.identifier)
+ self.assertEqual(["t1"], table.tag_manager().list_tags())
+ self.assertEqual(1, table.snapshot_manager().get_latest_snapshot().id)
+ rb = table.new_read_builder()
+ rows = rb.new_read().to_arrow(rb.new_scan().plan().splits())
+ self.assertEqual([1, 2, 3], sorted(rows.column("id").to_pylist()))
+
def test_create_and_get_tag(self):
self.catalog.create_tag(self.identifier, "t1")
response = self.catalog.get_tag(self.identifier, "t1")