github-actions[bot] commented on code in PR #39022:
URL: https://github.com/apache/doris/pull/39022#discussion_r1724492150


##########
be/src/vec/columns/column_object.cpp:
##########
@@ -1383,34 +1589,72 @@ Status ColumnObject::merge_sparse_to_root_column() {
     return Status::OK();
 }
 
-void ColumnObject::finalize_if_not() {
-    if (!is_finalized()) {
-        finalize();
-    }
-}
-
-void ColumnObject::finalize(bool ignore_sparse) {
+void ColumnObject::unnest(Subcolumns::NodePtr& entry, Subcolumns& subcolumns) 
const {
+    entry->data.finalize();
+    auto nested_column = 
entry->data.get_finalized_column_ptr()->assume_mutable();
+    auto* nested_column_nullable = 
assert_cast<ColumnNullable*>(nested_column.get());
+    auto* nested_column_array =
+            
assert_cast<ColumnArray*>(nested_column_nullable->get_nested_column_ptr().get());
+    auto& offset = nested_column_array->get_offsets_ptr();
+
+    auto* nested_object_nullable = assert_cast<ColumnNullable*>(
+            nested_column_array->get_data_ptr()->assume_mutable().get());
+    auto& nested_object_column =
+            
assert_cast<ColumnObject&>(nested_object_nullable->get_nested_column());
+    PathInData nested_path = entry->path;
+    for (auto& nested_entry : nested_object_column.subcolumns) {
+        if (nested_entry->data.least_common_type.get_base_type_id() == 
TypeIndex::Nothing) {
+            continue;
+        }
+        nested_entry->data.finalize();
+        PathInDataBuilder path_builder;
+        // format nested path
+        path_builder.append(nested_path.get_parts(), false);
+        path_builder.append(nested_entry->path.get_parts(), true);
+        auto subnested_column = ColumnArray::create(
+                
ColumnNullable::create(nested_entry->data.get_finalized_column_ptr(),
+                                       
nested_object_nullable->get_null_map_column_ptr()),
+                offset);
+        auto nullable_subnested_column = ColumnNullable::create(
+                subnested_column, 
nested_column_nullable->get_null_map_column_ptr());
+        auto type = make_nullable(
+                
std::make_shared<DataTypeArray>(nested_entry->data.least_common_type.get()));
+        Subcolumn subcolumn(nullable_subnested_column->assume_mutable(), type, 
is_nullable);
+        subcolumns.add(path_builder.build(), subcolumn);
+    }
+}
+
+void ColumnObject::finalize(FinalizeMode mode) {

Review Comment:
   warning: method 'finalize' can be made const 
[readability-make-member-function-const]
   
   be/src/vec/columns/column_object.h:346:
   ```diff
   -     void finalize(FinalizeMode mode);
   +     void finalize(FinalizeMode mode) const;
   ```
   
   ```suggestion
   void ColumnObject::finalize(FinalizeMode mode) const {
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to