ZhangHuiGui commented on code in PR #41092:
URL: https://github.com/apache/arrow/pull/41092#discussion_r1557084244


##########
cpp/src/arrow/array/array_nested.cc:
##########
@@ -222,6 +222,28 @@ Result<std::shared_ptr<Array>> FlattenListArray(const 
ListArrayT& list_array,
   const int64_t list_array_length = list_array.length();
   std::shared_ptr<arrow::Array> value_array = list_array.values();
 
+  // If the list array is nested list-array like 'list(list(int32))', then just
+  // flatten recursively.
+  if (is_list_like(value_array->type_id())) {
+    auto flatten_nested_list =
+        [&](const std::shared_ptr<arrow::Array>& varr) -> 
Result<std::shared_ptr<Array>> {
+      switch (varr->type_id()) {
+        case Type::LIST:
+          return FlattenListArray(checked_cast<const ListArray&>(*varr), 
memory_pool);
+        case Type::LARGE_LIST:
+          return FlattenListArray(checked_cast<const LargeListArray&>(*varr),
+                                  memory_pool);
+        case Type::FIXED_SIZE_LIST:
+          return FlattenListArray(checked_cast<const 
FixedSizeListArray&>(*varr),
+                                  memory_pool);
+        default:
+          return Status::Invalid("Unknown or unsupported arrow nested type: ",

Review Comment:
   List view related types are in `FlattenListViewArray` path.
   You're right, it's better to extract them into an independent function.



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