Skip to content

Commit

Permalink
don't create zero sized buffer (apache#11841)
Browse files Browse the repository at this point in the history
  • Loading branch information
XiangpengHao authored Aug 6, 2024
1 parent 4e278ca commit e19e982
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit e19e982

Please sign in to comment.