Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
don't create zero sized buffer
  • Loading branch information
XiangpengHao committed Aug 6, 2024
commit 708f9056d0d63b3b038ce5949290752eba7cfc75
8 changes: 5 additions & 3 deletions datafusion/physical-plan/src/coalesce_batches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down