pitrou commented on code in PR #36780:
URL: https://github.com/apache/arrow/pull/36780#discussion_r1272304079
##########
cpp/src/arrow/array/array_list_test.cc:
##########
@@ -233,6 +233,26 @@ class TestListArray : public ::testing::Test {
expected->null_bitmap()));
}
+ void TestFromArraysWithSlicedNullBitmap() {
+ std::vector<offset_type> offsets = {-1, -1, 0, 1, 1, 3};
Review Comment:
Perhaps we should spice things up by ensuring that the first sliced offset
is non-zero?
For example by adding a second check with `offsets_w_nulls->Slice(3, 3)`.
##########
cpp/src/arrow/array/array_list_test.cc:
##########
@@ -233,6 +233,26 @@ class TestListArray : public ::testing::Test {
expected->null_bitmap()));
}
+ void TestFromArraysWithSlicedNullBitmap() {
+ std::vector<offset_type> offsets = {-1, -1, 0, 1, 1, 3};
+ std::vector<bool> offsets_w_nulls_is_valid = {true, true, true, false,
true, true};
+
+ std::shared_ptr<Array> offsets_w_nulls;
+ ArrayFromVector<OffsetType, offset_type>(offsets_w_nulls_is_valid, offsets,
+ &offsets_w_nulls);
+
+ auto type = std::make_shared<T>(int32());
+ auto expected = std::dynamic_pointer_cast<ArrayType>(
+ ArrayFromJSON(type, "[[0], null, [0, null]]"));
+ auto values = expected->values();
+
+ // Apply an offset to the offsets array with nulls (GH-36776)
+ auto sliced_offsets = offsets_w_nulls->Slice(2, 4);
+ ASSERT_OK_AND_ASSIGN(auto result,
+ ArrayType::FromArrays(*sliced_offsets, *values,
pool_));
+ AssertArraysEqual(*result, *expected);
Review Comment:
```suggestion
ASSERT_OK(result->ValidateFull());
AssertArraysEqual(*result, *expected);
```
##########
cpp/src/arrow/array/array_list_test.cc:
##########
@@ -233,6 +233,26 @@ class TestListArray : public ::testing::Test {
expected->null_bitmap()));
}
+ void TestFromArraysWithSlicedNullBitmap() {
Review Comment:
For the record, do we already have a test with sliced offsets but no
validity bitmap?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]