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
11 changes: 11 additions & 0 deletions cpp/src/arrow/array/array_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,17 @@ TEST_F(TestFixedSizeListArray, NotEnoughValues) {
values = ArrayFromJSON(value_type_, "[1, 2, 3, 4]");
result_ = std::make_shared<FixedSizeListArray>(type_, 1, values);
ASSERT_OK(result_->ValidateFull());

// The array offset must be taken into account
result_ =
std::make_shared<FixedSizeListArray>(type_, 1, values, /*null_bitmap=*/nullptr,
/*null_count=*/0, /*offset=*/1);
ASSERT_OK(result_->ValidateFull());
result_ =
std::make_shared<FixedSizeListArray>(type_, 1, values, /*null_bitmap=*/nullptr,
/*null_count=*/0, /*offset=*/2);
ASSERT_RAISES(Invalid, result_->Validate());
ASSERT_RAISES(Invalid, result_->ValidateFull());
}

TEST_F(TestFixedSizeListArray, FlattenZeroLength) {
Expand Down
9 changes: 5 additions & 4 deletions cpp/src/arrow/array/validate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,12 @@ struct ValidateArrayImpl {
}

int64_t expected_values_length = -1;
if (MultiplyWithOverflow(data.length, list_size, &expected_values_length) ||
if (MultiplyWithOverflow(data.length + data.offset, list_size,
&expected_values_length) ||
values.length < expected_values_length) {
return Status::Invalid("Values length (", values.length,
") is less than the length (", data.length,
") multiplied by the value size (", list_size, ")");
return Status::Invalid(
"Values length (", values.length, ") is less than the length plus offset (",
data.length + data.offset, ") multiplied by the value size (", list_size, ")");
}

const Status child_valid = RecurseInto(values);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/c/bridge_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,7 @@ TEST_F(TestArrayImport, ListWithOffset) {
FillListLike(4, 0, 1, list_buffers_no_nulls1);
CheckImport(ArrayFromJSON(list(int8()), "[[], [3, 4, 5], [6], [7, 8]]"));

FillPrimitive(AddChild(), 9, 0, 0, primitive_buffers_no_nulls1_8);
FillPrimitive(AddChild(), 12, 0, 0, primitive_buffers_no_nulls1_8);
FillFixedSizeListLike(3, 0, 1, buffers_no_nulls_no_data);
CheckImport(
ArrayFromJSON(fixed_size_list(int8(), 3), "[[4, 5, 6], [7, 8, 9], [10, 11, 12]]"));
Expand All @@ -3166,7 +3166,7 @@ TEST_F(TestArrayImport, ListWithOffset) {
FillListLike(4, 0, 1, list_buffers_no_nulls1);
CheckImport(ArrayFromJSON(list(int8()), "[[], [5, 6, 7], [8], [9, 10]]"));

FillPrimitive(AddChild(), 9, 0, 2, primitive_buffers_no_nulls1_8);
FillPrimitive(AddChild(), 12, 0, 2, primitive_buffers_no_nulls1_8);
FillFixedSizeListLike(3, 0, 1, buffers_no_nulls_no_data);
CheckImport(ArrayFromJSON(fixed_size_list(int8(), 3),
"[[6, 7, 8], [9, 10, 11], [12, 13, 14]]"));
Expand Down
Loading