Support disabling output batch coalescing in HashJoinExec (and LimitedBatchCoalescer)

Đang mở
#27,109 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, databases, performance

Hướng nghiên cứu

Start with datafusion/physical-plan/src/joins/hash_join/stream.rs, where HashJoinStream uses LimitedBatchCoalescer, and inspect the coalescer implementation and configuration wiring for datafusion.execution.coalesce_batches. Then trace how HashJoinExec exposes operator settings and how other operators use the coalescer. Done means the setting can disable buffering while preserving empty-batch handling and fetch enforcement, with the execution configuration wired into the relevant operators.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Is your feature request related to a problem or challenge?

HashJoinStream unconditionally coalesces matched output rows across probe batches up to datafusion.execution.batch_size (8192) via LimitedBatchCoalescer:
https://github.com/apache/datafusion/blob/a7c7c08365a37f0b46bce81b1fd45515f3f18045/datafusion/physical-plan/src/joins/hash_join/stream.rs#L586-L587

When the probe side is expensive to pull from and already ordered for a downstream limit, coalescing across probe batches forces unnecessary work on the probe input before downstream operators can see already-matched rows. For example, when an incremental top-K probe scan feeds a chain of HashJoinExecs under ORDER BY ... LIMIT K, LimitPushdown can set fetch = Some(K) only on the outermost join; inner joins have fetch = None, so their LimitedBatchCoalescer buffers matches and repeatedly pulls from the probe scan until 8192 matches accumulate or the scan is exhausted.

Relatedly, datafusion.execution.coalesce_batches became a no-op after FilterExec (#18630), HashJoinExec (#18972), and RepartitionExec (#19449) internalized LimitedBatchCoalescer and #19622 removed the CoalesceBatches rule:
https://github.com/apache/datafusion/blob/a7c7c08365a37f0b46bce81b1fd45515f3f18045/datafusion/common/src/config.rs#L928-L932

Describe the solution you'd like

Support disabling coalescing on LimitedBatchCoalescer (via biggest_coalesce_batch_size = Some(0) so non-empty batches bypass buffering while empty batches are skipped and fetch is still enforced), exposed via:

  1. A per-operator HashJoinExec::with_coalesce_batches(bool) setting (so physical optimizer rules can disable coalescing selectively on demand-driven joins).
  2. Wiring datafusion.execution.coalesce_batches into operators that use LimitedBatchCoalescer.
Describe alternatives you've considered
  • Lowering datafusion.execution.batch_size globally degrades bulk operators and build-side scans in the same query.
  • A per-operator batch_size override on HashJoinExec still buffers batches of <= batch_size / 2 rows and shrinks the per-step match cap in lookup_join_hashmap.
Additional context

None.

Ngôn ngữ chính
Rust
Star
9.6k
Fork
2.6k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
345

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/datafusion

Tất cả issue của apache/datafusion

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.