Repository navigation
[python] Read scan.fallback-branch partitions in batch reads - #10898
Open
henriquejsza wants to merge 1 commit into
Open
henriquejsza wants to merge 1 commit into
henriquejsza wants to merge 1 commit into
Conversation
Batch reads in pypaimon only rejected scan.fallback-branch as a catalog option and never read it from the table, so a read left out the partitions that exist only in the fallback branch. Spark returns those rows, as the issue reports. FileStoreTable.new_read_builder now returns a FallbackReadBuilder when the table option scan.fallback-branch is set and the current branch is not the fallback branch itself. Mirroring Java's FallbackReadFileStoreTable, partitions present in the main branch are read from main and partitions that exist only in the fallback branch are read from the fallback branch. Filter, projection, read type and limit are applied to both branch scans, and the fallback branch must have the same row type as main. All branches share the same physical data files, so the merged splits are read with a single TableRead. Closes apache#10884 Signed-off-by: henriquejsza <henriquejsza@gmail.com>
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
Closes #10884.
pypaimon only checked
scan.fallback-branchin the catalog options, whereit is rejected, and never read it from the table. A batch read therefore
left out the partitions that exist only in the fallback branch, while
Spark's
SELECT ... FROM paimon.db.ton the same table returns them.FileStoreTable.new_read_buildernow returns aFallbackReadBuilderwhenthe table option
scan.fallback-branchis set and the current branch is notthe fallback branch itself. Mirroring Java's
FallbackReadFileStoreTable,partitions that exist in the main branch are read from main, and partitions
that exist only in the fallback branch are read from the fallback branch.
Filter, projection, read type and limit are applied to both branch scans,
and the fallback branch must have the same row type as main (same check Java
performs). All branches of a table share the same physical data files (only
snapshot, tag and schema metadata are branch scoped), so the merged splits
are read with a single
TableRead.Tests
pypaimon/tests/batch_read_fallback_branch_test.py:test_batch_read_includes_fallback_only_partitionsreproduces the issue(a partition missing from main is read from the fallback branch).
test_main_partition_shadows_fallbackasserts a partition present in mainis read from main, not the fallback.
test_no_fallback_option_reads_main_onlyasserts the read stays on mainwhen the option is unset.
flake8 --config=./dev/cfg.inipasses on the changed files, and the licenseheader check passes.