[python] Fix mock REST snapshot serialization#8546
Open
sundapeng wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The PyPaimon mock REST server did not persist the committed
Snapshotobject 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
nextRowIdis stored in the snapshot. After the first commit, the mock server dropsnextRowId; 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
Snapshotthrough the shared JSON serializer instead of maintaining a partial field mapping in the mock server. This preservesnextRowIdand any other current/future snapshot fields covered by the dataclass serializer.Tests
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