shangxinli commented on code in PR #1039:
URL: https://github.com/apache/iceberg-cpp/pull/1039#discussion_r4328473450


##########
src/iceberg/test/struct_like_test.cc:
##########
@@ -663,4 +666,120 @@ TEST(ArrowArrayStructLike, Accessor) {
   }
 }
 
+TEST(ArrowArrayStructLike, SlicedStruct) {
+  auto person_type =
+      ::arrow::struct_({::arrow::field("name", ::arrow::utf8(), 
/*nullable=*/false)});
+  auto root_type = ::arrow::struct_(
+      {::arrow::field("id", ::arrow::int64(), /*nullable=*/false),
+       ::arrow::field("person", person_type, /*nullable=*/false),
+       ::arrow::field("tags", ::arrow::list(::arrow::int32()), 
/*nullable=*/false)});
+
+  auto arrow_array = ::arrow::json::ArrayFromJSONString(root_type, R"([
+    {"id": 1, "person": {"name": "Alice"}, "tags": [1]},
+    {"id": 2, "person": {"name": "Bob"}, "tags": [2, 3]},
+    {"id": 3, "person": {"name": "Carol"}, "tags": []}])")
+                         .ValueOrDie();
+  auto sliced = arrow_array->Slice(1);
+
+  ArrowSchema c_schema;
+  ArrowArray c_array;
+  internal::ArrowSchemaGuard schema_guard(&c_schema);
+  internal::ArrowArrayGuard array_guard(&c_array);
+  ASSERT_TRUE(::arrow::ExportType(*root_type, &c_schema).ok());
+  ASSERT_TRUE(::arrow::ExportArray(*sliced, &c_array).ok());
+  ASSERT_EQ(c_array.offset, 1);

Review Comment:
   This slices only the parent, so every child keeps offset 0 and the GetField 
path never sees a child carrying its own offset. The map test below asserts 
children[0]->offset is 1 - worth doing the same here.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to