[python] Skip empty batches when advancing merge readers - #9820
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, and regression coverage is included.
Pull request overview
Fixes Python primary-key merge reads by skipping empty batches until a record or EOF.
Changes:
- Handles consecutive empty batches and closes readers at EOF.
- Adds regression coverage for ordering, deduplication, and reader closure.
File summaries
| File | Description |
|---|---|
paimon-python/pypaimon/tests/test_sort_merge_reader.py |
Adds regression coverage for empty-batch transitions. |
paimon-python/pypaimon/read/reader/sort_merge_reader.py |
Safely skips empty batches during merge advancement. |
Review details
- Files reviewed: 2/2 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 #9819.
Fix
AttributeError: 'NoneType' object has no attribute 'key'in primary-key merge reads when an input reader returns an empty batch after a non-empty batch.Change
Element.update()to skip empty batches until it finds a record or reaches EOF. ReturnTrueonly when a record is available, and close the reader at EOF.Tests
Add one regression test with two sorted inputs, including consecutive empty batches between records and before EOF. Assert merged output, deduplication, and reader closure. The test fails with the reported exception on the unchanged baseline and passes with this fix.
Local validation after rebasing onto
43e9ad701ebee6d9af8316f35533f4d0836a1fc0, with Python 3.12.6 and PyArrow 19.0.1:git diff --checkpassed.The full CI matrix has not been run locally.