This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new fec3c021e8 fix: remove incorrect debug assertion in BatchCoalescer  
(#9508)
fec3c021e8 is described below

commit fec3c021e85f34723250c413891f580657a1eb4f
Author: Tim-53 <[email protected]>
AuthorDate: Mon Mar 9 13:45:16 2026 +0100

    fix: remove incorrect debug assertion in BatchCoalescer  (#9508)
    
    # Which issue does this PR close?
    
     - Closes https://github.com/apache/arrow-rs/issues/9506
    
    
    # Rationale for this change
    
    `Vec::reserve(n)` does not guarantee exact capacity, Rust's
    `MIN_NON_ZERO_CAP` optimization means `reserve(2)` gives capacity = 4
    for most numeric types, causing `debug_assert_eq!(capacity, batch_size)`
    to panic in debug mode when `batch_size < 4`.
    # What changes are included in this PR?
    
    Replace `reserve` with `reserve_exact` in `ensure_capacity` in both
    `InProgressPrimitiveArray` and `InProgressByteViewArray`.
    `reserve_exact` skips the amortized growth optimization and allocates
    exactly the requested capacity, making the assertion correct.
    
    # Are these changes tested?
    No. This only fixes an incorrect debug assertion.
    
    # Are there any user-facing changes?
    No
---
 arrow-select/src/coalesce/byte_view.rs | 1 -
 arrow-select/src/coalesce/primitive.rs | 1 -
 2 files changed, 2 deletions(-)

diff --git a/arrow-select/src/coalesce/byte_view.rs 
b/arrow-select/src/coalesce/byte_view.rs
index bca811fff1..6062cd5e77 100644
--- a/arrow-select/src/coalesce/byte_view.rs
+++ b/arrow-select/src/coalesce/byte_view.rs
@@ -101,7 +101,6 @@ impl<B: ByteViewType> InProgressByteViewArray<B> {
         if self.views.capacity() == 0 {
             self.views.reserve(self.batch_size);
         }
-        debug_assert_eq!(self.views.capacity(), self.batch_size);
     }
 
     /// Finishes in progress buffer, if any
diff --git a/arrow-select/src/coalesce/primitive.rs 
b/arrow-select/src/coalesce/primitive.rs
index 69dad221bd..a7f2fb32ce 100644
--- a/arrow-select/src/coalesce/primitive.rs
+++ b/arrow-select/src/coalesce/primitive.rs
@@ -58,7 +58,6 @@ impl<T: ArrowPrimitiveType> InProgressPrimitiveArray<T> {
         if self.current.capacity() == 0 {
             self.current.reserve(self.batch_size);
         }
-        debug_assert_eq!(self.current.capacity(), self.batch_size);
     }
 }
 

Reply via email to