[python] Preserve declared primary-key order in merge reads - #9801
Open
wangzhigang1999 wants to merge 1 commit into
Open
wangzhigang1999 wants to merge 1 commit into
wangzhigang1999 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Fixes merge-read deduplication by preserving declared composite primary-key order.
Changes:
- Builds merge keys from ordered trimmed primary-key fields.
- Adds coverage for projections, partitions, reordered keys, and schema changes.
File summaries
| File | Summary |
|---|---|
paimon-python/pypaimon/tests/schema_evolution_pk_read_test.py |
Tests primary-key position changes across schemas. |
paimon-python/pypaimon/tests/reader_primary_key_test.py |
Tests composite-key ordering and projections. |
paimon-python/pypaimon/read/split_read.py |
Aligns merge-key construction with writer sort order. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Fixes #9800
When a composite primary key is declared in a different order from the table columns, PyPaimon can return both the old and updated row. For example, four orders with
PRIMARY KEY (order_id, customer_id)produce five rows after one update whencustomer_idprecedesorder_idin the table schema.Build merge-read key fields from the table's ordered trimmed primary-key fields, matching the writer's sort order. This preserves field IDs, types and the storage format. Regression coverage checks complete merged results, value-only projections, partition-key trimming and a primary-key column position change across schema versions.
Tests
Validation: the new regression tests fail before the fix; all 70 tests in
reader_primary_key_test,schema_evolution_pk_read_test,projection_predicate_index_testandtest_sequence_field_readpass after it. Flake8 on changed files andgit diff --checkpass. Local validation used Python 3.12.6 and PyArrow 19.0.1.