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 2b2904d211 [python] Fix mock REST snapshot serialization (#8546)
2b2904d211 is described below

commit 2b2904d21174378382c76b34ed0158c7a995821c
Author: Dapeng Sun(孙大鹏) <[email protected]>
AuthorDate: Mon Jul 13 10:32:38 2026 +0800

    [python] Fix mock REST snapshot serialization (#8546)
---
 .../rest/rest_catalog_commit_snapshot_test.py      | 29 ++++++++++++++++++++++
 paimon-python/pypaimon/tests/rest/rest_server.py   | 18 +-------------
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git 
a/paimon-python/pypaimon/tests/rest/rest_catalog_commit_snapshot_test.py 
b/paimon-python/pypaimon/tests/rest/rest_catalog_commit_snapshot_test.py
index 0854ef3d3a..975c6f643b 100644
--- a/paimon-python/pypaimon/tests/rest/rest_catalog_commit_snapshot_test.py
+++ b/paimon-python/pypaimon/tests/rest/rest_catalog_commit_snapshot_test.py
@@ -296,6 +296,35 @@ class TestRESTCatalogCommitSnapshot(unittest.TestCase):
 
 class TestRESTCommit(RESTBaseTest):
 
+    def test_multiple_row_tracking_commits_preserve_all_rows(self):
+        pa_schema = pa.schema([('id', pa.int32())])
+        schema = Schema.from_pyarrow_schema(
+            pa_schema,
+            options={
+                'row-tracking.enabled': 'true',
+                'data-evolution.enabled': 'true',
+            })
+        table_name = 'default.test_row_tracking_commits'
+        self.rest_catalog.create_table(table_name, schema, False)
+        table = self.rest_catalog.get_table(table_name)
+
+        for values in ([1, 2, 3], [4, 5, 6]):
+            write_builder = table.new_batch_write_builder()
+            table_write = write_builder.new_write()
+            table_commit = write_builder.new_commit()
+            table_write.write_arrow(
+                pa.Table.from_pydict({'id': values}, schema=pa_schema))
+            table_commit.commit(table_write.prepare_commit())
+            table_write.close()
+            table_commit.close()
+
+        read_builder = table.new_read_builder()
+        actual = read_builder.new_read().to_arrow(
+            read_builder.new_scan().plan().splits())
+        self.assertEqual(actual.num_rows, 6)
+        self.assertEqual(
+            sorted(actual.column('id').to_pylist()), [1, 2, 3, 4, 5, 6])
+
     def test_commit_succeeded_on_server_but_client_fails(self):
         pa_schema = pa.schema([('id', pa.int32()), ('name', pa.string())])
         opts = {
diff --git a/paimon-python/pypaimon/tests/rest/rest_server.py 
b/paimon-python/pypaimon/tests/rest/rest_server.py
index 55cf2d6baa..d1fbd528b1 100755
--- a/paimon-python/pypaimon/tests/rest/rest_server.py
+++ b/paimon-python/pypaimon/tests/rest/rest_server.py
@@ -1263,9 +1263,7 @@ class RESTCatalogServer:
 
     def _write_snapshot_files(self, identifier: Identifier, snapshot, 
statistics):
         """Write snapshot and related files to the file system"""
-        import json
         import os
-        import uuid
 
         # Construct table path: {warehouse}/{database}/{table}
         table_path = os.path.join(self.data_path, self.warehouse, 
identifier.get_database_name(),
@@ -1278,22 +1276,8 @@ class RESTCatalogServer:
 
         # Write snapshot file (snapshot-{id})
         snapshot_file = os.path.join(snapshot_dir, f"snapshot-{snapshot.id}")
-        snapshot_data = {
-            "version": getattr(snapshot, 'version', 3),
-            "id": snapshot.id,
-            "schemaId": getattr(snapshot, 'schema_id', 0),
-            "baseManifestList": getattr(snapshot, 'base_manifest_list', 
f"manifest-list-{uuid.uuid4()}"),
-            "deltaManifestList": getattr(snapshot, 'delta_manifest_list', 
f"manifest-list-{uuid.uuid4()}"),
-            "totalRecordCount": getattr(snapshot, 'total_record_count'),
-            "deltaRecordCount": getattr(snapshot, 'delta_record_count'),
-            "commitUser": getattr(snapshot, 'commit_user', 'rest-server'),
-            "commitIdentifier": getattr(snapshot, 'commit_identifier', 1),
-            "commitKind": getattr(snapshot, 'commit_kind', 'APPEND'),
-            "timeMillis": getattr(snapshot, 'time_millis', 1703721600000)
-        }
-
         with open(snapshot_file, 'w') as f:
-            json.dump(snapshot_data, f, indent=2)
+            f.write(JSON.to_json(snapshot))
 
         # Write LATEST file
         latest_file = os.path.join(snapshot_dir, "LATEST")

Reply via email to