Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions cpp/src/parquet/decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,9 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl<ByteArrayType> {
int32_t batch_size =
std::min<int32_t>(kBufferSize, num_values - num_appended - null_count);
int num_indices = idx_decoder_.GetBatch(indices, batch_size);
if (ARROW_PREDICT_FALSE(num_indices < 1)) {
return Status::Invalid("Invalid number of indices: ", num_indices);
}

int i = 0;
while (true) {
Expand Down
16 changes: 16 additions & 0 deletions cpp/src/parquet/encoding_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,22 @@ TEST_F(DictEncoding, CheckDecodeArrowNonNullDictBuilder) {
this->CheckDecodeArrowNonNullUsingDictBuilder();
}

TEST_F(DictEncoding, CheckDecodeArrowDictBuilderTruncatedIndices) {
// The index stream ends before num_values - null_count indices have been
// decoded, so a refill of the index buffer returns no indices at all
InitTestCase(::arrow::binary(), /*null_probability=*/0.5, /*create_dict=*/true);
dict_decoder_->SetData(num_values_, buffer_->data(),
static_cast<int>(buffer_->size()) / 2);
auto builder = CreateDictBuilder();
EXPECT_THROW_THAT(
[&]() {
decoder_->DecodeArrow(num_values_, null_count_, valid_bits_, 0, builder.get());
},
ParquetException,
::testing::Property(&ParquetException::what,
::testing::HasSubstr("Invalid number of indices")));
}

TEST_F(DictEncoding, CheckDecodeIndicesSpaced) {
for (auto np : null_probabilities_) {
InitTestCase(::arrow::binary(), np, /*create_dict=*/true);
Expand Down
Loading