github-actions[bot] commented on code in PR #60352:
URL: https://github.com/apache/doris/pull/60352#discussion_r3019830237
##########
be/src/exprs/function/array/function_array_utils.cpp:
##########
@@ -59,9 +59,18 @@ bool extract_column_array_info(const IColumn& src,
ColumnArrayExecutionData& dat
data.nested_type->get_primitive_type() != PrimitiveType::TYPE_VARIANT)
{
// set variant root column/type to from column/type
auto variant = ColumnVariant::create(0, data.variant_enable_doc_mode);
- auto nullable_nested_type = make_nullable(data.nested_type);
- auto nullable_col = make_nullable(data.nested_col);
- variant->create_root(nullable_nested_type,
std::move(*nullable_col).mutate());
+ auto root_col = data.nested_col->assume_mutable();
+ if (data.nested_type->is_nullable() && !root_col->is_nullable()) {
+ auto null_map = ColumnUInt8::create();
+ auto& null_map_data = null_map->get_data();
+ null_map_data.resize(root_col->size(), 0);
+ if (data.nested_nullmap_data != nullptr) {
+ std::copy(data.nested_nullmap_data, data.nested_nullmap_data +
root_col->size(),
+ null_map_data.begin());
+ }
+ root_col = ColumnNullable::create(std::move(root_col),
std::move(null_map));
+ }
+ variant->create_root(data.nested_type, std::move(root_col));
data.nested_col = variant->get_ptr();
}
Review Comment:
`ColumnVariant` roots need to stay nullable here. Before this patch, this
path always did `make_nullable(data.nested_type)` +
`make_nullable(data.nested_col)` before `create_root()`. Now we only rebuild a
`ColumnNullable` when the element type itself is nullable, so `explode()` on a
VARIANT root like `array<int>` starts producing a scalar VARIANT with a
non-nullable root.
Downstream code still keys off `var.get_root()->is_nullable()` /
`var.get_root_type()->is_nullable()` to preserve null semantics
(`be/src/exec/common/variant_util.cpp:2121-2124`,
`be/src/exprs/function/function_variant_element.cpp:93-98`). With the new
non-nullable root, casts / element extraction on the exploded result can lose
NULL handling. Please keep the wrapped root nullable here and add a regression
that exercises the real `vexplode` variant path.
--
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]