Skip to content

[python] Fix Arrow offset overflow in merge condition filtering - #9678

Merged
JingsongLi merged 1 commit into
apache:masterfrom
XiaoHongbo-Hope:codex/fix-self-merge-string-overflow
Sep 8, 2026
Merged

JingsongLi merged 1 commit into
apache:masterfrom
XiaoHongbo-Hope:codex/fix-self-merge-string-overflow

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Fix conditional self-merge failures when the combined size of Arrow string, binary, or other 32-bit-offset columns exceeds INT32_MAX.

filter_batch previously registered every input RecordBatch in one DataFusion partition. DataFusion could concatenate those batches while evaluating the condition, causing an offset overflow even though each individual Arrow batch was valid.

Changes

  • Register each input RecordBatch as a separate DataFusion partition.
  • Use collect_partitioned() and rebuild the Arrow table in partition order.
  • Disable DataFusion round-robin repartitioning so physical partitions retain the original batch order.
  • Add low-memory offset-overflow and real DataFusion multi-batch order regression tests.

The fix preserves the existing Arrow schema instead of casting columns to large_string or large_binary.

Tests

  • Real DataFusion 54 order test with four 20,000-row batches
  • DataFusion 54 ordering stress check: 30/30 runs ordered after the fix (the old plan reordered 10/10)
  • 22 merge-condition unit tests passed
  • flake8, py_compile, and git diff --check passed

@XiaoHongbo-Hope
XiaoHongbo-Hope marked this pull request as ready for review September 8, 2026 04:19
@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the codex/fix-self-merge-string-overflow branch from d7b25a1 to 6519f5b Compare September 8, 2026 07:10
@XiaoHongbo-Hope
XiaoHongbo-Hope force-pushed the codex/fix-self-merge-string-overflow branch from 6519f5b to b3ef901 Compare September 8, 2026 07:12
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi
JingsongLi merged commit e8a8886 into apache:master Sep 8, 2026
9 checks passed
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.

2 participants