Skip to content

[python] Fix mock REST snapshot serialization#8546

Open
sundapeng wants to merge 1 commit into
apache:masterfrom
sundapeng:fix/pypaimon-rest-snapshot-serialization
Open

[python] Fix mock REST snapshot serialization#8546
sundapeng wants to merge 1 commit into
apache:masterfrom
sundapeng:fix/pypaimon-rest-snapshot-serialization

Conversation

@sundapeng

@sundapeng sundapeng commented Jul 10, 2026

Copy link
Copy Markdown
Member

Purpose

The PyPaimon mock REST server did not persist the committed Snapshot object as-is. Instead, it rebuilt snapshot files from a small hand-written JSON payload, which silently dropped optional snapshot fields.

This breaks row-tracking/data-evolution tests because nextRowId is stored in the snapshot. After the first commit, the mock server drops nextRowId; the next commit reloads the snapshot with no row-id counter and starts assigning row ids from the beginning again. Those duplicated row ids make later rows shadow earlier rows, so appending [1, 2, 3] and then [4, 5, 6] can read back only [4, 5, 6].

This PR writes the original Snapshot through the shared JSON serializer instead of maintaining a partial field mapping in the mock server. This preserves nextRowId and any other current/future snapshot fields covered by the dataclass serializer.

Tests

  • Added TestRESTCommit.test_multiple_row_tracking_commits_preserve_all_rows, which performs two REST commits on a row-tracking/data-evolution table and verifies all six rows are readable.
  • python -m pytest -q paimon-python/pypaimon/tests/rest/rest_catalog_commit_snapshot_test.py::TestRESTCommit::test_multiple_row_tracking_commits_preserve_all_rows

The mock REST server rebuilt snapshot JSON from a fixed field list and dropped nextRowId. Subsequent row-tracking commits then reused row ids and hid previously committed rows. Serialize the Snapshot dataclass directly and cover the failure with a two-commit REST regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant