Skip to content

Commit

Permalink
concatenate should ensure null slots contain an empty string view
Browse files Browse the repository at this point in the history
  • Loading branch information
bkietz committed Oct 10, 2023
1 parent 15e5846 commit 8bececb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 11 additions & 0 deletions cpp/src/arrow/array/concatenate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "arrow/util/int_util_overflow.h"
#include "arrow/util/logging.h"
#include "arrow/util/ree_util.h"
#include "arrow/visit_data_inline.h"
#include "arrow/visit_type_inline.h"

namespace arrow {
Expand Down Expand Up @@ -256,6 +257,16 @@ class ConcatenateImpl {
}
}

if (out_->buffers[0] != nullptr) {
i = in_[0]->length;
VisitNullBitmapInline(
out_->buffers[0]->data(), in_[0]->length, out_->length, out_->null_count,
[&] { ++i; },
[&] {
views[i++] = {}; // overwrite views under null bits with an empty view
});
}

out_->buffers[1] = std::move(view_buffer);
return Status::OK();
}
Expand Down
4 changes: 1 addition & 3 deletions cpp/src/arrow/visit_data_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ struct ArraySpanInlineVisitor<T, enable_if_binary_view_like<T>> {
auto* data_buffers = arr.GetVariadicBuffers().data();
VisitBitBlocksVoid(
arr.buffers[0].data, arr.offset, arr.length,
[&](int64_t index) {
valid_func(util::FromBinaryView(s[index], data_buffers));
},
[&](int64_t index) { valid_func(util::FromBinaryView(s[index], data_buffers)); },
std::forward<NullFunc>(null_func));
}
};
Expand Down

0 comments on commit 8bececb

Please sign in to comment.