Skip to content

Commit e19e982

Browse files
authored
don't create zero sized buffer (#11841)
1 parent 4e278ca commit e19e982

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

datafusion/physical-plan/src/coalesce_batches.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,10 @@ fn gc_string_view_batch(batch: &RecordBatch) -> RecordBatch {
492492
if actual_buffer_size > (ideal_buffer_size * 2) {
493493
// We set the block size to `ideal_buffer_size` so that the new StringViewArray only has one buffer, which accelerate later concat_batches.
494494
// See https://github.com/apache/arrow-rs/issues/6094 for more details.
495-
let mut builder = StringViewBuilder::with_capacity(s.len())
496-
.with_block_size(ideal_buffer_size as u32);
495+
let mut builder = StringViewBuilder::with_capacity(s.len());
496+
if ideal_buffer_size > 0 {
497+
builder = builder.with_block_size(ideal_buffer_size as u32);
498+
}
497499

498500
for v in s.iter() {
499501
builder.append_option(v);
@@ -802,7 +804,7 @@ mod tests {
802804
impl StringViewTest {
803805
/// Create a `StringViewArray` with the parameters specified in this struct
804806
fn build(self) -> StringViewArray {
805-
let mut builder = StringViewBuilder::with_capacity(100);
807+
let mut builder = StringViewBuilder::with_capacity(100).with_block_size(8192);
806808
loop {
807809
for &v in self.strings.iter() {
808810
builder.append_option(v);

0 commit comments

Comments
 (0)