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

lzljs3620320 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 ccf80ba2b7 [python] add list tag for TagManager (#7264)
ccf80ba2b7 is described below

commit ccf80ba2b7c5d7c201bef7226ac0408cc41a46d8
Author: cos120 <[email protected]>
AuthorDate: Thu Feb 12 12:17:13 2026 +0800

    [python] add list tag for TagManager (#7264)
---
 paimon-python/pypaimon/filesystem/local_file_io.py    |  1 +
 paimon-python/pypaimon/table/file_store_table.py      | 10 ++++++++++
 paimon-python/pypaimon/tag/tag_manager.py             | 18 ++++++++++++++++++
 .../pypaimon/tests/table/simple_table_test.py         | 19 +++++++++++++++++++
 4 files changed, 48 insertions(+)

diff --git a/paimon-python/pypaimon/filesystem/local_file_io.py 
b/paimon-python/pypaimon/filesystem/local_file_io.py
index ed2c7d8117..8e8fd46552 100644
--- a/paimon-python/pypaimon/filesystem/local_file_io.py
+++ b/paimon-python/pypaimon/filesystem/local_file_io.py
@@ -118,6 +118,7 @@ class LocalFileIO(FileIO):
                 stat_info = file_path.stat()
                 self.path = str(file_path.absolute())
                 self.original_path = original_path
+                self.base_name = os.path.basename(original_path)
                 self.size = stat_info.st_size if file_path.is_file() else None
                 self.type = (
                     pyarrow.fs.FileType.Directory if file_path.is_dir()
diff --git a/paimon-python/pypaimon/table/file_store_table.py 
b/paimon-python/pypaimon/table/file_store_table.py
index e23d9cec75..64423e12dc 100644
--- a/paimon-python/pypaimon/table/file_store_table.py
+++ b/paimon-python/pypaimon/table/file_store_table.py
@@ -139,6 +139,16 @@ class FileStoreTable(Table):
         tag_mgr = self.tag_manager()
         return tag_mgr.delete_tag(tag_name)
 
+    def list_tag(self):
+        """
+        List all tags.
+
+        Returns:
+            List of name of tag
+        """
+        tag_mgr = self.tag_manager()
+        return tag_mgr.list_tag()
+
     def path_factory(self) -> 'FileStorePathFactory':
         from pypaimon.utils.file_store_path_factory import FileStorePathFactory
 
diff --git a/paimon-python/pypaimon/tag/tag_manager.py 
b/paimon-python/pypaimon/tag/tag_manager.py
index 7f63f4ac06..19e98129a3 100644
--- a/paimon-python/pypaimon/tag/tag_manager.py
+++ b/paimon-python/pypaimon/tag/tag_manager.py
@@ -16,6 +16,7 @@
 #  under the License.
 
 import logging
+import os
 from typing import Optional
 
 from pypaimon.common.file_io import FileIO
@@ -140,6 +141,23 @@ class TagManager:
 
         self._create_or_replace_tag(snapshot, tag_name)
 
+    def list_tag(self):
+        """List all tags."""
+        result = []
+        for tag_file in self.file_io.list_status(self.tag_directory()):
+            tag_file_name = None
+            if hasattr(tag_file, 'base_name'):
+                tag_file_name = tag_file.base_name
+            else:
+                try:
+                    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)
+        return result
+
     def _create_or_replace_tag(
             self,
             snapshot: Snapshot,
diff --git a/paimon-python/pypaimon/tests/table/simple_table_test.py 
b/paimon-python/pypaimon/tests/table/simple_table_test.py
index 4a4d024f39..bf4458d9ad 100644
--- a/paimon-python/pypaimon/tests/table/simple_table_test.py
+++ b/paimon-python/pypaimon/tests/table/simple_table_test.py
@@ -191,10 +191,29 @@ class SimpleTableTest(unittest.TestCase):
         self.assertIsNotNone(tag)
         self.assertEqual(tag.id, 1)
 
+        table_write = write_builder.new_write()
+        table_commit = write_builder.new_commit()
+        data = pa.Table.from_pydict({
+            'pt': [1, 1],
+            'k': [10, 20],
+            'v': [100, 200]
+        }, schema=self.pa_schema)
+        table_write.write_arrow(data)
+        table_commit.commit(table_write.prepare_commit())
+        table_write.close()
+        table_commit.close()
+
+        table.create_tag("test_tag_2")
+        all_tags = set(table.list_tag())
+        self.assertEqual(all_tags, {"test_tag", "test_tag_2"})
+
         # Delete the tag
         result = table.delete_tag("test_tag")
         self.assertTrue(result)
 
+        all_tags = table.list_tag()
+        self.assertEqual(all_tags, ["test_tag_2"])
+
         # Verify tag no longer exists
         self.assertFalse(tag_manager.tag_exists("test_tag"))
 

Reply via email to