Coverage Report

Created: 2026-07-08 17:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/vectorized_agg_fn.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "exprs/vectorized_agg_fn.h"
19
20
#include <fmt/format.h>
21
#include <fmt/ranges.h> // IWYU pragma: keep
22
#include <gen_cpp/Exprs_types.h>
23
#include <gen_cpp/PlanNodes_types.h>
24
#include <glog/logging.h>
25
26
#include <memory>
27
#include <ostream>
28
#include <string_view>
29
30
#include "common/config.h"
31
#include "common/object_pool.h"
32
#include "core/block/block.h"
33
#include "core/block/column_with_type_and_name.h"
34
#include "core/block/materialize_block.h"
35
#include "core/data_type/data_type_agg_state.h"
36
#include "core/data_type/data_type_factory.hpp"
37
#include "exec/common/util.hpp"
38
#include "exprs/aggregate/aggregate_function_ai_agg.h"
39
#include "exprs/aggregate/aggregate_function_java_udaf.h"
40
#include "exprs/aggregate/aggregate_function_python_udaf.h"
41
#include "exprs/aggregate/aggregate_function_rpc.h"
42
#include "exprs/aggregate/aggregate_function_simple_factory.h"
43
#include "exprs/aggregate/aggregate_function_sort.h"
44
#include "exprs/aggregate/aggregate_function_state_merge.h"
45
#include "exprs/aggregate/aggregate_function_state_union.h"
46
#include "exprs/vexpr.h"
47
#include "exprs/vexpr_context.h"
48
49
static constexpr int64_t BE_VERSION_THAT_SUPPORT_NULLABLE_CHECK = 8;
50
51
namespace doris {
52
class RowDescriptor;
53
class Arena;
54
class BufferWritable;
55
class IColumn;
56
} // namespace doris
57
58
namespace doris {
59
60
template <class FunctionType>
61
AggregateFunctionPtr get_agg_state_function(const DataTypes& argument_types,
62
460
                                            DataTypePtr return_type) {
63
460
    return FunctionType::create(
64
460
            assert_cast<const DataTypeAggState*>(argument_types[0].get())->get_nested_function(),
65
460
            argument_types, return_type);
66
460
}
_ZN5doris22get_agg_state_functionINS_19AggregateStateUnionEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EES8_
Line
Count
Source
62
127
                                            DataTypePtr return_type) {
63
127
    return FunctionType::create(
64
127
            assert_cast<const DataTypeAggState*>(argument_types[0].get())->get_nested_function(),
65
127
            argument_types, return_type);
66
127
}
_ZN5doris22get_agg_state_functionINS_19AggregateStateMergeEEESt10shared_ptrINS_18IAggregateFunctionEERKSt6vectorIS2_IKNS_9IDataTypeEESaIS8_EES8_
Line
Count
Source
62
333
                                            DataTypePtr return_type) {
63
333
    return FunctionType::create(
64
333
            assert_cast<const DataTypeAggState*>(argument_types[0].get())->get_nested_function(),
65
333
            argument_types, return_type);
66
333
}
67
68
AggFnEvaluator::AggFnEvaluator(const TExprNode& desc, const bool without_key,
69
                               const bool is_window_function)
70
111k
        : _fn(desc.fn),
71
111k
          _is_merge(desc.agg_expr.is_merge_agg),
72
111k
          _without_key(without_key),
73
111k
          _is_window_function(is_window_function),
74
111k
          _data_type(DataTypeFactory::instance().create_data_type(
75
18.4E
                  desc.fn.ret_type, desc.__isset.is_nullable ? desc.is_nullable : true)) {
76
111k
    if (desc.agg_expr.__isset.param_types) {
77
111k
        const auto& param_types = desc.agg_expr.param_types;
78
111k
        for (const auto& param_type : param_types) {
79
90.8k
            _argument_types_with_sort.push_back(
80
90.8k
                    DataTypeFactory::instance().create_data_type(param_type));
81
90.8k
        }
82
111k
    }
83
111k
}
84
85
Status AggFnEvaluator::create(ObjectPool* pool, const TExpr& desc, const TSortInfo& sort_info,
86
                              const bool without_key, const bool is_window_function,
87
111k
                              AggFnEvaluator** result) {
88
111k
    *result =
89
111k
            pool->add(AggFnEvaluator::create_unique(desc.nodes[0], without_key, is_window_function)
90
111k
                              .release());
91
111k
    auto& agg_fn_evaluator = *result;
92
111k
    int node_idx = 0;
93
205k
    for (int i = 0; i < desc.nodes[0].num_children; ++i) {
94
94.6k
        ++node_idx;
95
94.6k
        VExprSPtr expr;
96
94.6k
        VExprContextSPtr ctx;
97
94.6k
        RETURN_IF_ERROR(VExpr::create_tree_from_thrift(desc.nodes, &node_idx, expr, ctx));
98
94.6k
        agg_fn_evaluator->_input_exprs_ctxs.push_back(ctx);
99
94.6k
    }
100
101
111k
    auto sort_size = sort_info.ordering_exprs.size();
102
111k
    auto real_arguments_size = agg_fn_evaluator->_argument_types_with_sort.size() - sort_size;
103
    // Child arguments contains [real arguments, order by arguments], we pass the arguments
104
    // to the order by functions
105
111k
    for (int i = 0; i < sort_size; ++i) {
106
104
        agg_fn_evaluator->_sort_description.emplace_back(real_arguments_size + i,
107
104
                                                         sort_info.is_asc_order[i] ? 1 : -1,
108
104
                                                         sort_info.nulls_first[i] ? -1 : 1);
109
104
    }
110
111
    // Pass the real arguments to get functions
112
201k
    for (int i = 0; i < real_arguments_size; ++i) {
113
90.7k
        agg_fn_evaluator->_real_argument_types.emplace_back(
114
90.7k
                agg_fn_evaluator->_argument_types_with_sort[i]);
115
90.7k
    }
116
111k
    return Status::OK();
117
111k
}
118
119
Status AggFnEvaluator::prepare(RuntimeState* state, const RowDescriptor& desc,
120
                               const SlotDescriptor* intermediate_slot_desc,
121
111k
                               const SlotDescriptor* output_slot_desc) {
122
111k
    DCHECK(intermediate_slot_desc != nullptr);
123
111k
    DCHECK(_intermediate_slot_desc == nullptr);
124
111k
    _output_slot_desc = output_slot_desc;
125
111k
    _intermediate_slot_desc = intermediate_slot_desc;
126
127
111k
    Status status = VExpr::prepare(_input_exprs_ctxs, state, desc);
128
111k
    RETURN_IF_ERROR(status);
129
130
111k
    DataTypes tmp_argument_types;
131
111k
    tmp_argument_types.reserve(_input_exprs_ctxs.size());
132
133
111k
    std::vector<std::string_view> child_expr_name;
134
135
    // prepare for argument
136
111k
    for (auto& _input_exprs_ctx : _input_exprs_ctxs) {
137
94.6k
        auto data_type = _input_exprs_ctx->root()->data_type();
138
94.6k
        tmp_argument_types.emplace_back(data_type);
139
94.6k
        child_expr_name.emplace_back(_input_exprs_ctx->root()->expr_name());
140
94.6k
    }
141
142
111k
    std::vector<std::string> column_names;
143
111k
    for (const auto& expr_ctx : _input_exprs_ctxs) {
144
94.6k
        const auto& root = expr_ctx->root();
145
94.6k
        if (!root->expr_name().empty() && !root->is_constant()) {
146
70.3k
            column_names.emplace_back(root->expr_name());
147
70.3k
        }
148
94.6k
    }
149
150
111k
    const DataTypes& argument_types =
151
111k
            _real_argument_types.empty() ? tmp_argument_types : _real_argument_types;
152
153
111k
    if (_fn.binary_type == TFunctionBinaryType::JAVA_UDF) {
154
115
        if (config::enable_java_support) {
155
115
            _function = AggregateJavaUdaf::create(_fn, argument_types, _data_type);
156
115
            RETURN_IF_ERROR(static_cast<AggregateJavaUdaf*>(_function.get())->check_udaf(_fn));
157
115
        } else {
158
0
            return Status::InternalError(
159
0
                    "Java UDAF is not enabled, you can change be config enable_java_support to "
160
0
                    "true and restart be.");
161
0
        }
162
111k
    } else if (_fn.binary_type == TFunctionBinaryType::PYTHON_UDF) {
163
587
        if (config::enable_python_udf_support) {
164
586
            _function = AggregatePythonUDAF::create(_fn, argument_types, _data_type);
165
586
            RETURN_IF_ERROR(static_cast<AggregatePythonUDAF*>(_function.get())->open());
166
586
            LOG(INFO) << fmt::format(
167
586
                    "Created Python UDAF: {}, runtime_version: {}, function_code: {}",
168
586
                    _fn.name.function_name, _fn.runtime_version, _fn.function_code);
169
586
        } else {
170
1
            return Status::InternalError(
171
1
                    "Python UDAF is not enabled, you can change be config "
172
1
                    "enable_python_udf_support to true and restart be.");
173
1
        }
174
110k
    } else if (_fn.binary_type == TFunctionBinaryType::RPC) {
175
0
        _function = AggregateRpcUdaf::create(_fn, argument_types, _data_type);
176
110k
    } else if (_fn.binary_type == TFunctionBinaryType::AGG_STATE) {
177
461
        if (argument_types.size() != 1) {
178
0
            return Status::InternalError("Agg state Function must input 1 argument but get {}",
179
0
                                         argument_types.size());
180
0
        }
181
461
        if (argument_types[0]->is_nullable()) {
182
0
            return Status::InternalError("Agg state function input type must be not nullable");
183
0
        }
184
461
        if (argument_types[0]->get_primitive_type() != PrimitiveType::TYPE_AGG_STATE) {
185
0
            return Status::InternalError(
186
0
                    "Agg state function input type must be agg_state but get {}",
187
0
                    argument_types[0]->get_family_name());
188
0
        }
189
190
461
        std::string type_function_name =
191
461
                assert_cast<const DataTypeAggState*>(argument_types[0].get())->get_function_name();
192
461
        if (type_function_name + AGG_UNION_SUFFIX == _fn.name.function_name) {
193
127
            if (_data_type->is_nullable()) {
194
0
                return Status::InternalError(
195
0
                        "Union function return type must be not nullable, real={}",
196
0
                        _data_type->get_name());
197
0
            }
198
127
            if (_data_type->get_primitive_type() != PrimitiveType::TYPE_AGG_STATE) {
199
0
                return Status::InternalError(
200
0
                        "Union function return type must be AGG_STATE, real={}",
201
0
                        _data_type->get_name());
202
0
            }
203
127
            _function = get_agg_state_function<AggregateStateUnion>(argument_types, _data_type);
204
334
        } else if (type_function_name + AGG_MERGE_SUFFIX == _fn.name.function_name) {
205
333
            auto type = assert_cast<const DataTypeAggState*>(argument_types[0].get())
206
333
                                ->get_nested_function()
207
333
                                ->get_return_type();
208
333
            if (!type->equals(*_data_type)) {
209
0
                return Status::InternalError("{}'s expect return type is {}, but input {}",
210
0
                                             argument_types[0]->get_name(), type->get_name(),
211
0
                                             _data_type->get_name());
212
0
            }
213
333
            _function = get_agg_state_function<AggregateStateMerge>(argument_types, _data_type);
214
333
        } else {
215
1
            return Status::InternalError("{} not match function {}", argument_types[0]->get_name(),
216
1
                                         _fn.name.function_name);
217
1
        }
218
110k
    } else {
219
110k
        const bool is_foreach =
220
110k
                AggregateFunctionSimpleFactory::is_foreach(_fn.name.function_name) ||
221
110k
                AggregateFunctionSimpleFactory::is_foreachv2(_fn.name.function_name);
222
        // Here, only foreachv1 needs special treatment, and v2 can follow the normal code logic.
223
110k
        if (AggregateFunctionSimpleFactory::is_foreach(_fn.name.function_name)) {
224
0
            _function = AggregateFunctionSimpleFactory::instance().get(
225
0
                    _fn.name.function_name, argument_types, _data_type,
226
0
                    AggregateFunctionSimpleFactory::result_nullable_by_foreach(_data_type),
227
0
                    state->be_exec_version(),
228
0
                    {.is_window_function = _is_window_function,
229
0
                     .is_foreach = is_foreach,
230
0
                     .enable_aggregate_function_null_v2 =
231
0
                             state->enable_aggregate_function_null_v2(),
232
0
                     .new_version_percentile =
233
0
                             state->query_options().__isset.new_version_percentile &&
234
0
                             state->query_options().new_version_percentile,
235
0
                     .column_names = std::move(column_names)});
236
110k
        } else {
237
110k
            _function = AggregateFunctionSimpleFactory::instance().get(
238
110k
                    _fn.name.function_name, argument_types, _data_type, _data_type->is_nullable(),
239
110k
                    state->be_exec_version(),
240
110k
                    {.is_window_function = _is_window_function,
241
110k
                     .is_foreach = is_foreach,
242
110k
                     .enable_aggregate_function_null_v2 =
243
110k
                             state->enable_aggregate_function_null_v2(),
244
110k
                     .new_version_percentile =
245
110k
                             state->query_options().__isset.new_version_percentile &&
246
110k
                             state->query_options().new_version_percentile,
247
110k
                     .column_names = std::move(column_names)});
248
110k
        }
249
110k
    }
250
111k
    if (_function == nullptr) {
251
0
        return Status::InternalError("Agg Function {} is not implemented", _fn.signature);
252
0
    }
253
254
111k
    if (!_sort_description.empty()) {
255
85
        _function = transform_to_sort_agg_function(_function, _argument_types_with_sort,
256
85
                                                   _sort_description, state);
257
85
    }
258
259
111k
    if (_fn.name.function_name == "ai_agg") {
260
0
        _function->set_query_context(state->get_query_ctx());
261
0
    }
262
263
    // Foreachv2, like foreachv1, does not check the return type,
264
    // because its return type is related to the internal agg.
265
111k
    if (!AggregateFunctionSimpleFactory::is_foreach(_fn.name.function_name) &&
266
111k
        !AggregateFunctionSimpleFactory::is_foreachv2(_fn.name.function_name)) {
267
111k
        if (state->be_exec_version() >= BE_VERSION_THAT_SUPPORT_NULLABLE_CHECK) {
268
111k
            RETURN_IF_ERROR(
269
111k
                    _function->verify_result_type(_without_key, argument_types, _data_type));
270
111k
        }
271
111k
    }
272
111k
    _expr_name = fmt::format("{}({})", _fn.name.function_name, child_expr_name);
273
111k
    return Status::OK();
274
111k
}
275
276
111k
Status AggFnEvaluator::open(RuntimeState* state) {
277
111k
    return VExpr::open(_input_exprs_ctxs, state);
278
111k
}
279
280
3.10M
void AggFnEvaluator::create(AggregateDataPtr place) {
281
3.10M
    _function->create(place);
282
3.10M
}
283
284
3.01M
void AggFnEvaluator::destroy(AggregateDataPtr place) {
285
3.01M
    _function->destroy(place);
286
3.01M
}
287
288
189k
Status AggFnEvaluator::execute_single_add(Block* block, AggregateDataPtr place, Arena& arena) {
289
189k
    RETURN_IF_ERROR(_calc_argument_columns(block));
290
189k
    _function->check_input_columns_type(_agg_columns.data());
291
189k
    _function->add_batch_single_place(block->rows(), place, _agg_columns.data(), arena);
292
189k
    return Status::OK();
293
189k
}
294
295
Status AggFnEvaluator::execute_batch_add(Block* block, size_t offset, AggregateDataPtr* places,
296
98.0k
                                         Arena& arena, bool agg_many) {
297
98.0k
    RETURN_IF_ERROR(_calc_argument_columns(block));
298
98.0k
    _function->check_input_columns_type(_agg_columns.data());
299
98.0k
    _function->add_batch(block->rows(), places, offset, _agg_columns.data(), arena, agg_many);
300
98.0k
    return Status::OK();
301
98.0k
}
302
303
Status AggFnEvaluator::execute_batch_add_selected(Block* block, size_t offset,
304
2
                                                  AggregateDataPtr* places, Arena& arena) {
305
2
    RETURN_IF_ERROR(_calc_argument_columns(block));
306
2
    _function->check_input_columns_type(_agg_columns.data());
307
2
    _function->add_batch_selected(block->rows(), places, offset, _agg_columns.data(), arena);
308
2
    return Status::OK();
309
2
}
310
311
Status AggFnEvaluator::streaming_agg_serialize_to_column(Block* block, MutableColumnPtr& dst,
312
27
                                                         const size_t num_rows, Arena& arena) {
313
27
    RETURN_IF_ERROR(_calc_argument_columns(block));
314
27
    _function->check_input_columns_type(_agg_columns.data());
315
27
    _function->streaming_agg_serialize_to_column(_agg_columns.data(), dst, num_rows, arena);
316
27
    return Status::OK();
317
27
}
318
319
void AggFnEvaluator::add_range_single_place(int64_t partition_start, int64_t partition_end,
320
                                            int64_t frame_start, int64_t frame_end,
321
                                            AggregateDataPtr place, const IColumn** columns,
322
                                            Arena& arena, UInt8* use_null_result,
323
54.4k
                                            UInt8* could_use_previous_result) {
324
54.4k
    _function->check_input_columns_type(columns);
325
54.4k
    _function->add_range_single_place(partition_start, partition_end, frame_start, frame_end, place,
326
54.4k
                                      columns, arena, use_null_result, could_use_previous_result);
327
54.4k
}
328
329
void AggFnEvaluator::execute_function_with_incremental(
330
        int64_t partition_start, int64_t partition_end, int64_t frame_start, int64_t frame_end,
331
        AggregateDataPtr place, const IColumn** columns, Arena& arena, bool previous_is_nul,
332
1.43k
        bool end_is_nul, bool has_null, UInt8* use_null_result, UInt8* could_use_previous_result) {
333
1.43k
    _function->check_input_columns_type(columns);
334
1.43k
    _function->execute_function_with_incremental(
335
1.43k
            partition_start, partition_end, frame_start, frame_end, place, columns, arena,
336
1.43k
            previous_is_nul, end_is_nul, has_null, use_null_result, could_use_previous_result);
337
1.43k
}
338
339
82.5k
void AggFnEvaluator::insert_result_info(AggregateDataPtr place, IColumn* column) {
340
82.5k
    _function->check_result_column_type(*column);
341
82.5k
    _function->insert_result_into(place, *column);
342
82.5k
}
343
344
void AggFnEvaluator::insert_result_info_vec(const std::vector<AggregateDataPtr>& places,
345
56.9k
                                            size_t offset, IColumn* column, const size_t num_rows) {
346
56.9k
    _function->check_result_column_type(*column);
347
56.9k
    _function->insert_result_into_vec(places, offset, *column, num_rows);
348
56.9k
}
349
350
void AggFnEvaluator::insert_result_info_range(ConstAggregateDataPtr place, IColumn* column,
351
55.4k
                                              size_t start, size_t end) {
352
55.4k
    _function->check_result_column_type(*column);
353
55.4k
    _function->insert_result_into_range(place, *column, start, end);
354
55.4k
}
355
356
20.1k
void AggFnEvaluator::reset(AggregateDataPtr place) {
357
20.1k
    _function->reset(place);
358
20.1k
}
359
360
0
std::string AggFnEvaluator::debug_string(const std::vector<AggFnEvaluator*>& exprs) {
361
0
    std::stringstream out;
362
0
    out << "[";
363
364
0
    for (int i = 0; i < exprs.size(); ++i) {
365
0
        out << (i == 0 ? "" : " ") << exprs[i]->debug_string();
366
0
    }
367
368
0
    out << "]";
369
0
    return out.str();
370
0
}
371
372
0
std::string AggFnEvaluator::debug_string() const {
373
0
    std::stringstream out;
374
0
    out << "AggFnEvaluator(";
375
0
    out << _fn.signature;
376
0
    out << ")";
377
0
    return out.str();
378
0
}
379
380
287k
Status AggFnEvaluator::_calc_argument_columns(Block* block) {
381
287k
    SCOPED_TIMER(_expr_timer);
382
287k
    _agg_columns.resize(_input_exprs_ctxs.size());
383
287k
    std::vector<int> column_ids(_input_exprs_ctxs.size());
384
511k
    for (int i = 0; i < _input_exprs_ctxs.size(); ++i) {
385
223k
        int column_id = -1;
386
223k
        RETURN_IF_ERROR(_input_exprs_ctxs[i]->execute(block, &column_id));
387
223k
        column_ids[i] = column_id;
388
223k
    }
389
287k
    materialize_block_inplace(*block, column_ids.data(),
390
287k
                              column_ids.data() + _input_exprs_ctxs.size());
391
511k
    for (int i = 0; i < _input_exprs_ctxs.size(); ++i) {
392
223k
        _agg_columns[i] = block->get_by_position(column_ids[i]).column.get();
393
223k
    }
394
287k
    return Status::OK();
395
287k
}
396
397
243k
AggFnEvaluator* AggFnEvaluator::clone(RuntimeState* state, ObjectPool* pool) {
398
243k
    return pool->add(AggFnEvaluator::create_unique(*this, state).release());
399
243k
}
400
401
AggFnEvaluator::AggFnEvaluator(AggFnEvaluator& evaluator, RuntimeState* state)
402
243k
        : _fn(evaluator._fn),
403
243k
          _is_merge(evaluator._is_merge),
404
243k
          _without_key(evaluator._without_key),
405
243k
          _is_window_function(evaluator._is_window_function),
406
243k
          _argument_types_with_sort(evaluator._argument_types_with_sort),
407
243k
          _real_argument_types(evaluator._real_argument_types),
408
243k
          _intermediate_slot_desc(evaluator._intermediate_slot_desc),
409
243k
          _output_slot_desc(evaluator._output_slot_desc),
410
243k
          _sort_description(evaluator._sort_description),
411
243k
          _data_type(evaluator._data_type),
412
243k
          _function(evaluator._function),
413
243k
          _expr_name(evaluator._expr_name),
414
243k
          _agg_columns(evaluator._agg_columns) {
415
243k
    if (evaluator._fn.binary_type == TFunctionBinaryType::JAVA_UDF) {
416
604
        DataTypes tmp_argument_types;
417
604
        tmp_argument_types.reserve(evaluator._input_exprs_ctxs.size());
418
        // prepare for argument
419
700
        for (auto& _input_exprs_ctx : evaluator._input_exprs_ctxs) {
420
700
            auto data_type = _input_exprs_ctx->root()->data_type();
421
700
            tmp_argument_types.emplace_back(data_type);
422
700
        }
423
604
        const DataTypes& argument_types =
424
604
                _real_argument_types.empty() ? tmp_argument_types : _real_argument_types;
425
604
        _function = AggregateJavaUdaf::create(evaluator._fn, argument_types, evaluator._data_type);
426
604
        THROW_IF_ERROR(static_cast<AggregateJavaUdaf*>(_function.get())->check_udaf(evaluator._fn));
427
604
    }
428
243k
    DCHECK(_function != nullptr);
429
430
243k
    _input_exprs_ctxs.resize(evaluator._input_exprs_ctxs.size());
431
449k
    for (size_t i = 0; i < _input_exprs_ctxs.size(); i++) {
432
205k
        WARN_IF_ERROR(evaluator._input_exprs_ctxs[i]->clone(state, _input_exprs_ctxs[i]), "");
433
205k
    }
434
243k
}
435
436
Status AggFnEvaluator::check_agg_fn_output(uint32_t key_size,
437
                                           const std::vector<AggFnEvaluator*>& agg_fn,
438
34.0k
                                           const RowDescriptor& output_row_desc) {
439
34.0k
    auto name_and_types = VectorizedUtils::create_name_and_data_types(output_row_desc);
440
126k
    for (uint32_t i = key_size, j = 0; i < name_and_types.size(); i++, j++) {
441
92.5k
        auto&& [name, column_type] = name_and_types[i];
442
92.5k
        auto agg_return_type = agg_fn[j]->get_return_type();
443
92.5k
        if (!column_type->equals(*agg_return_type)) {
444
14.5k
            if (!column_type->is_nullable() || agg_return_type->is_nullable() ||
445
14.5k
                !remove_nullable(column_type)->equals(*agg_return_type)) {
446
0
                return Status::InternalError(
447
0
                        "column_type not match data_types in agg node, column_type={}, "
448
0
                        "data_types={},column name={}",
449
0
                        column_type->get_name(), agg_return_type->get_name(), name);
450
0
            }
451
14.5k
        }
452
92.5k
    }
453
34.0k
    return Status::OK();
454
34.0k
}
455
456
751k
bool AggFnEvaluator::is_blockable() const {
457
751k
    return _function->is_blockable() ||
458
751k
           std::any_of(_input_exprs_ctxs.begin(), _input_exprs_ctxs.end(),
459
750k
                       [](VExprContextSPtr ctx) { return ctx->root()->is_blockable(); });
460
751k
}
461
462
} // namespace doris