eldenmoon commented on code in PR #44533:
URL: https://github.com/apache/doris/pull/44533#discussion_r1862817026


##########
be/src/vec/exprs/table_function/vexplode.cpp:
##########
@@ -37,6 +42,34 @@ VExplodeTableFunction::VExplodeTableFunction() {
     _fn_name = "vexplode";
 }
 
+Status VExplodeTableFunction::_process_init_variant(Block* block, int 
value_column_idx) {
+    // explode variant array
+    const auto& variant_column = check_and_get_column<ColumnObject>(
+            remove_nullable(block->get_by_position(value_column_idx)
+                                    .column->convert_to_full_column_if_const())
+                    .get());
+    _detail.output_as_variant = true;
+    if (!variant_column->is_null_root()) {
+        _array_column = variant_column->get_root();
+        // We need to wrap the output nested column within a variant column.
+        // Otherwise the type is missmatched
+        const auto* array_type = check_and_get_data_type<DataTypeArray>(
+                remove_nullable(variant_column->get_root_type()).get());
+        if (array_type == nullptr) {
+            return Status::NotSupported("explode not support none array type 
{}",
+                                        
variant_column->get_root_type()->get_name());
+        }
+        _detail.nested_type = array_type->get_nested_type();
+    } else {
+        // null root, use nothing type
+        _array_column = 
ColumnNullable::create(ColumnArray::create(ColumnNothing::create(0)),
+                                               ColumnUInt8::create(0));
+        
_array_column->assume_mutable()->insert_many_defaults(variant_column->size());
+        _detail.nested_type = std::make_shared<DataTypeNothing>();

Review Comment:
   it's redundant in column object case



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