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/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new e19e9825f2 don't create zero sized buffer (#11841)
e19e9825f2 is described below

commit e19e9825f2e127621782f5fdcd5f22e04ace8ee8
Author: Xiangpeng Hao <[email protected]>
AuthorDate: Tue Aug 6 20:19:12 2024 +0800

    don't create zero sized buffer (#11841)
---
 datafusion/physical-plan/src/coalesce_batches.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/datafusion/physical-plan/src/coalesce_batches.rs 
b/datafusion/physical-plan/src/coalesce_batches.rs
index b822ec2daf..de42a55ad3 100644
--- a/datafusion/physical-plan/src/coalesce_batches.rs
+++ b/datafusion/physical-plan/src/coalesce_batches.rs
@@ -492,8 +492,10 @@ fn gc_string_view_batch(batch: &RecordBatch) -> 
RecordBatch {
             if actual_buffer_size > (ideal_buffer_size * 2) {
                 // We set the block size to `ideal_buffer_size` so that the 
new StringViewArray only has one buffer, which accelerate later concat_batches.
                 // See https://github.com/apache/arrow-rs/issues/6094 for more 
details.
-                let mut builder = StringViewBuilder::with_capacity(s.len())
-                    .with_block_size(ideal_buffer_size as u32);
+                let mut builder = StringViewBuilder::with_capacity(s.len());
+                if ideal_buffer_size > 0 {
+                    builder = builder.with_block_size(ideal_buffer_size as 
u32);
+                }
 
                 for v in s.iter() {
                     builder.append_option(v);
@@ -802,7 +804,7 @@ mod tests {
     impl StringViewTest {
         /// Create a `StringViewArray` with the parameters specified in this 
struct
         fn build(self) -> StringViewArray {
-            let mut builder = StringViewBuilder::with_capacity(100);
+            let mut builder = 
StringViewBuilder::with_capacity(100).with_block_size(8192);
             loop {
                 for &v in self.strings.iter() {
                     builder.append_option(v);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to