[Refactor](function) opt the exec of function with null column (#16256)

This commit is contained in:
HappenLee
2023-02-01 15:56:31 +08:00
committed by GitHub
parent ca73c60442
commit aaae1497cd
5 changed files with 85 additions and 89 deletions

View File

@ -217,11 +217,12 @@ Status PreparedFunctionImpl::default_implementation_for_nulls(
}
if (null_presence.has_nullable) {
Block temporary_block = create_block_with_nested_columns(block, args, result);
auto [temporary_block, new_args, new_result] =
create_block_with_nested_columns(block, args, result);
RETURN_IF_ERROR(execute_without_low_cardinality_columns(
context, temporary_block, args, result, temporary_block.rows(), dry_run));
context, temporary_block, new_args, new_result, temporary_block.rows(), dry_run));
block.get_by_position(result).column =
wrap_in_nullable(temporary_block.get_by_position(result).column, block, args,
wrap_in_nullable(temporary_block.get_by_position(new_result).column, block, args,
result, input_rows_count);
*executed = true;
return Status::OK();
@ -295,10 +296,9 @@ DataTypePtr FunctionBuilderImpl::get_return_type_without_low_cardinality(
}
if (null_presence.has_nullable) {
ColumnNumbers numbers(arguments.size());
for (size_t i = 0; i < arguments.size(); i++) {
numbers[i] = i;
}
Block nested_block = create_block_with_nested_columns(Block(arguments), numbers);
std::iota(numbers.begin(), numbers.end(), 0);
auto [nested_block, _] =
create_block_with_nested_columns(Block(arguments), numbers, false);
auto return_type = get_return_type_impl(
ColumnsWithTypeAndName(nested_block.begin(), nested_block.end()));
return make_nullable(return_type);