Skip to content

[python] Read scan.fallback-branch partitions in batch reads - #10898

Open
henriquejsza wants to merge 1 commit into
apache:masterfrom
henriquejsza:python-10884-batch-read-fallback-branch
Open

henriquejsza wants to merge 1 commit into
apache:masterfrom
henriquejsza:python-10884-batch-read-fallback-branch

Conversation

@henriquejsza

Copy link
Copy Markdown

Purpose

Closes #10884.

pypaimon only checked scan.fallback-branch in the catalog options, where
it 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.t on the same table returns them.

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 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

  • Added pypaimon/tests/batch_read_fallback_branch_test.py:
    • test_batch_read_includes_fallback_only_partitions reproduces the issue
      (a partition missing from main is read from the fallback branch).
    • test_main_partition_shadows_fallback asserts a partition present in main
      is read from main, not the fallback.
    • test_no_fallback_option_reads_main_only asserts the read stays on main
      when the option is unset.
  • flake8 --config=./dev/cfg.ini passes on the changed files, and the license
    header check passes.

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>
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.

[Bug] [Python] Batch reads ignore the table option scan.fallback-branch

1 participant