lidavidm commented on code in PR #12706:
URL: https://github.com/apache/arrow/pull/12706#discussion_r939141794


##########
cpp/src/arrow/array/array_test.cc:
##########
@@ -78,6 +78,24 @@ class TestArray : public ::testing::Test {
   MemoryPool* pool_;
 };
 
+TEST_F(TestArray, ValidateFullNullableList) {
+  auto f1 = field("f1", int32(), /*nullable=*/false);
+  auto ty = list(f1);
+  auto array = ArrayFromJSON(ty, "[[0, 1, 2, null], null, [4, 5]]");
+  ASSERT_RAISES(Invalid, array->ValidateFull());
+}
+
+TEST_F(TestArray, ValidateFullNullableFixedSizeList) {
+  auto f0 = field("f0", int32(), /*nullable=*/false);
+  auto type = fixed_size_list(f0, 2);
+  auto array_nonull = ArrayFromJSON(type, "[[0, 1], [3,4], [2, 3]]");
+  auto array = ArrayFromJSON(type, "[[0, 1], null, [2, 5]]");

Review Comment:
   We can build the array manually here then?
   
   ```
   auto inner = ArrayFromJSON(f0->type(), "[0, 1, 2, 3, 4, 5]");
   std::shared_ptr<Buffer> null_bitmap;
   ASSERT_OK(BitmapFromVector({1, 0, 1}, &null_bitmap));
   auto array = std::make_shared<FixedSizeListArray>(type, /*length=*/3, inner);
   ASSERT_OK(array->ValidateFull());
   ```



##########
cpp/src/arrow/array/array_union_test.cc:
##########
@@ -70,6 +70,22 @@ TEST(TestUnionArray, TestSliceEquals) {
   CheckUnion(batch->column(1));
 }
 
+TEST(TestSparseUnionArray, ValidateFullNullable) {
+  auto ty = sparse_union(
+      {field("ints", int64()), field("strs", utf8(), /*nullable*/ false)}, {2, 
7});
+  auto ints = ArrayFromJSON(int64(), "[0, 1, 2, 3]");
+  auto strs = ArrayFromJSON(utf8(), R"(["a", null, "c", "d"])");

Review Comment:
   I think this makes sense? A union is always non-nullable



##########
cpp/src/arrow/array/array_test.cc:
##########
@@ -78,6 +78,26 @@ class TestArray : public ::testing::Test {
   MemoryPool* pool_;
 };
 
+TEST_F(TestArray, ValidateFullNullableList) {
+  auto f1 = field("f1", int32(), /*nullable=*/false);
+  auto ty = list(f1);
+  auto array = ArrayFromJSON(ty, "[[0, 1, 2, 3], null, [4, 5]]");
+  auto array_nested_null = ArrayFromJSON(ty, "[[0, 1, 2, null], [3,6], [4, 
5]]");
+  // ASSERT_RAISES(Invalid, array->ValidateFull());

Review Comment:
   Similar to the example below, we can use CopyBufferFromVector to manually 
assemble the array we want



-- 
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]

Reply via email to