Coverage Report

Created: 2025-12-21 13:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/be/src/vec/exprs/vexpr.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 "vec/exprs/vexpr.h"
19
20
#include <fmt/format.h>
21
#include <gen_cpp/Exprs_types.h>
22
#include <gen_cpp/FrontendService_types.h>
23
#include <thrift/protocol/TDebugProtocol.h>
24
25
#include <algorithm>
26
#include <boost/algorithm/string/split.hpp>
27
#include <boost/iterator/iterator_facade.hpp>
28
#include <cstdint>
29
#include <memory>
30
#include <stack>
31
#include <string_view>
32
#include <utility>
33
34
#include "common/config.h"
35
#include "common/exception.h"
36
#include "common/status.h"
37
#include "olap/inverted_index_parser.h"
38
#include "olap/rowset/segment_v2/ann_index/ann_search_params.h"
39
#include "olap/rowset/segment_v2/ann_index/ann_topn_runtime.h"
40
#include "pipeline/pipeline_task.h"
41
#include "runtime/define_primitive_type.h"
42
#include "vec/columns/column_vector.h"
43
#include "vec/core/field.h"
44
#include "vec/data_types/data_type_array.h"
45
#include "vec/data_types/data_type_decimal.h"
46
#include "vec/data_types/data_type_factory.hpp"
47
#include "vec/data_types/data_type_nullable.h"
48
#include "vec/data_types/data_type_number.h"
49
#include "vec/exprs/varray_literal.h"
50
#include "vec/exprs/vcase_expr.h"
51
#include "vec/exprs/vcast_expr.h"
52
#include "vec/exprs/vcolumn_ref.h"
53
#include "vec/exprs/vcompound_pred.h"
54
#include "vec/exprs/vcondition_expr.h"
55
#include "vec/exprs/vectorized_fn_call.h"
56
#include "vec/exprs/vexpr_context.h"
57
#include "vec/exprs/vexpr_fwd.h"
58
#include "vec/exprs/vin_predicate.h"
59
#include "vec/exprs/vinfo_func.h"
60
#include "vec/exprs/virtual_slot_ref.h"
61
#include "vec/exprs/vlambda_function_call_expr.h"
62
#include "vec/exprs/vlambda_function_expr.h"
63
#include "vec/exprs/vliteral.h"
64
#include "vec/exprs/vmap_literal.h"
65
#include "vec/exprs/vmatch_predicate.h"
66
#include "vec/exprs/vsearch.h"
67
#include "vec/exprs/vslot_ref.h"
68
#include "vec/exprs/vstruct_literal.h"
69
#include "vec/runtime/timestamptz_value.h"
70
#include "vec/utils/util.hpp"
71
72
namespace doris {
73
#include "common/compile_check_begin.h"
74
75
class RowDescriptor;
76
class RuntimeState;
77
78
// NOLINTBEGIN(readability-function-cognitive-complexity)
79
// NOLINTBEGIN(readability-function-size)
80
TExprNode create_texpr_node_from(const void* data, const PrimitiveType& type, int precision,
81
17
                                 int scale) {
82
17
    TExprNode node;
83
84
17
    switch (type) {
85
0
    case TYPE_BOOLEAN: {
86
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_BOOLEAN>(data, &node));
87
0
        break;
88
0
    }
89
0
    case TYPE_TINYINT: {
90
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_TINYINT>(data, &node));
91
0
        break;
92
0
    }
93
0
    case TYPE_SMALLINT: {
94
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_SMALLINT>(data, &node));
95
0
        break;
96
0
    }
97
5
    case TYPE_INT: {
98
5
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_INT>(data, &node));
99
5
        break;
100
5
    }
101
11
    case TYPE_BIGINT: {
102
11
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_BIGINT>(data, &node));
103
11
        break;
104
11
    }
105
11
    case TYPE_LARGEINT: {
106
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_LARGEINT>(data, &node));
107
0
        break;
108
0
    }
109
0
    case TYPE_FLOAT: {
110
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_FLOAT>(data, &node));
111
0
        break;
112
0
    }
113
0
    case TYPE_DOUBLE: {
114
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DOUBLE>(data, &node));
115
0
        break;
116
0
    }
117
0
    case TYPE_DATEV2: {
118
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATEV2>(data, &node));
119
0
        break;
120
0
    }
121
0
    case TYPE_DATETIMEV2: {
122
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIMEV2>(data, &node, precision, scale));
123
0
        break;
124
0
    }
125
0
    case TYPE_DATE: {
126
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATE>(data, &node));
127
0
        break;
128
0
    }
129
0
    case TYPE_DATETIME: {
130
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIME>(data, &node));
131
0
        break;
132
0
    }
133
0
    case TYPE_DECIMALV2: {
134
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMALV2>(data, &node, precision, scale));
135
0
        break;
136
0
    }
137
0
    case TYPE_DECIMAL32: {
138
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL32>(data, &node, precision, scale));
139
0
        break;
140
0
    }
141
0
    case TYPE_DECIMAL64: {
142
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL64>(data, &node, precision, scale));
143
0
        break;
144
0
    }
145
0
    case TYPE_DECIMAL128I: {
146
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL128I>(data, &node, precision, scale));
147
0
        break;
148
0
    }
149
0
    case TYPE_DECIMAL256: {
150
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DECIMAL256>(data, &node, precision, scale));
151
0
        break;
152
0
    }
153
0
    case TYPE_CHAR: {
154
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_CHAR>(data, &node));
155
0
        break;
156
0
    }
157
0
    case TYPE_VARCHAR: {
158
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_VARCHAR>(data, &node));
159
0
        break;
160
0
    }
161
0
    case TYPE_STRING: {
162
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_STRING>(data, &node));
163
0
        break;
164
0
    }
165
0
    case TYPE_IPV4: {
166
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_IPV4>(data, &node));
167
0
        break;
168
0
    }
169
0
    case TYPE_IPV6: {
170
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_IPV6>(data, &node));
171
0
        break;
172
0
    }
173
0
    case TYPE_TIMEV2: {
174
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_TIMEV2>(data, &node, precision, scale));
175
0
        break;
176
0
    }
177
1
    case TYPE_TIMESTAMPTZ: {
178
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_TIMESTAMPTZ>(data, &node, precision, scale));
179
1
        break;
180
1
    }
181
1
    default:
182
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "runtime filter meet invalid type {}",
183
0
                        int(type));
184
17
    }
185
17
    return node;
186
17
}
187
188
TExprNode create_texpr_node_from(const vectorized::Field& field, const PrimitiveType& type,
189
23
                                 int precision, int scale) {
190
23
    TExprNode node;
191
23
    switch (type) {
192
1
    case TYPE_BOOLEAN: {
193
1
        const auto& storage = static_cast<bool>(
194
1
                field.get<typename PrimitiveTypeTraits<TYPE_BOOLEAN>::NearestFieldType>());
195
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_BOOLEAN>(&storage, &node));
196
1
        break;
197
1
    }
198
1
    case TYPE_TINYINT: {
199
0
        const auto& storage = static_cast<int8_t>(
200
0
                field.get<typename PrimitiveTypeTraits<TYPE_TINYINT>::NearestFieldType>());
201
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_TINYINT>(&storage, &node));
202
0
        break;
203
0
    }
204
1
    case TYPE_SMALLINT: {
205
1
        const auto& storage = static_cast<int16_t>(
206
1
                field.get<typename PrimitiveTypeTraits<TYPE_SMALLINT>::NearestFieldType>());
207
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_SMALLINT>(&storage, &node));
208
1
        break;
209
1
    }
210
1
    case TYPE_INT: {
211
1
        const auto& storage = static_cast<int32_t>(
212
1
                field.get<typename PrimitiveTypeTraits<TYPE_INT>::NearestFieldType>());
213
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_INT>(&storage, &node));
214
1
        break;
215
1
    }
216
1
    case TYPE_BIGINT: {
217
1
        const auto& storage = static_cast<int64_t>(
218
1
                field.get<typename PrimitiveTypeTraits<TYPE_BIGINT>::NearestFieldType>());
219
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_BIGINT>(&storage, &node));
220
1
        break;
221
1
    }
222
1
    case TYPE_LARGEINT: {
223
1
        const auto& storage = static_cast<int128_t>(
224
1
                field.get<typename PrimitiveTypeTraits<TYPE_LARGEINT>::NearestFieldType>());
225
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_LARGEINT>(&storage, &node));
226
1
        break;
227
1
    }
228
1
    case TYPE_FLOAT: {
229
1
        const auto& storage = static_cast<float>(
230
1
                field.get<typename PrimitiveTypeTraits<TYPE_FLOAT>::NearestFieldType>());
231
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_FLOAT>(&storage, &node));
232
1
        break;
233
1
    }
234
1
    case TYPE_DOUBLE: {
235
1
        const auto& storage = static_cast<double>(
236
1
                field.get<typename PrimitiveTypeTraits<TYPE_DOUBLE>::NearestFieldType>());
237
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DOUBLE>(&storage, &node));
238
1
        break;
239
1
    }
240
1
    case TYPE_DATEV2: {
241
1
        DateV2Value<DateV2ValueType> storage =
242
1
                binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(static_cast<uint32_t>(
243
1
                        field.get<typename PrimitiveTypeTraits<TYPE_DATEV2>::NearestFieldType>()));
244
245
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATEV2>(&storage, &node));
246
1
        break;
247
1
    }
248
1
    case TYPE_DATETIMEV2: {
249
1
        DateV2Value<DateTimeV2ValueType> storage = binary_cast<uint64_t,
250
1
                                                               DateV2Value<DateTimeV2ValueType>>(
251
1
                field.get<typename PrimitiveTypeTraits<TYPE_DATETIMEV2>::NearestFieldType>());
252
253
1
        THROW_IF_ERROR(
254
1
                create_texpr_literal_node<TYPE_DATETIMEV2>(&storage, &node, precision, scale));
255
1
        break;
256
1
    }
257
1
    case TYPE_TIMESTAMPTZ: {
258
1
        TimestampTzValue storage = binary_cast<uint64_t, TimestampTzValue>(
259
1
                field.get<typename PrimitiveTypeTraits<TYPE_TIMESTAMPTZ>::NearestFieldType>());
260
261
1
        THROW_IF_ERROR(
262
1
                create_texpr_literal_node<TYPE_TIMESTAMPTZ>(&storage, &node, precision, scale));
263
1
        break;
264
1
    }
265
1
    case TYPE_DATE: {
266
1
        VecDateTimeValue storage = binary_cast<int64_t, doris::VecDateTimeValue>(
267
1
                field.get<typename PrimitiveTypeTraits<TYPE_DATE>::NearestFieldType>());
268
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATE>(&storage, &node));
269
1
        break;
270
1
    }
271
1
    case TYPE_DATETIME: {
272
1
        VecDateTimeValue storage = binary_cast<int64_t, doris::VecDateTimeValue>(
273
1
                field.get<typename PrimitiveTypeTraits<TYPE_DATETIME>::NearestFieldType>());
274
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_DATETIME>(&storage, &node));
275
1
        break;
276
1
    }
277
1
    case TYPE_DECIMALV2: {
278
1
        const auto& storage =
279
1
                field.get<typename PrimitiveTypeTraits<TYPE_DECIMALV2>::NearestFieldType>()
280
1
                        .get_value();
281
282
1
        THROW_IF_ERROR(
283
1
                create_texpr_literal_node<TYPE_DECIMALV2>(&storage, &node, precision, scale));
284
1
        break;
285
1
    }
286
2
    case TYPE_DECIMAL32: {
287
2
        const auto& storage =
288
2
                field.get<typename PrimitiveTypeTraits<TYPE_DECIMAL32>::NearestFieldType>()
289
2
                        .get_value();
290
2
        THROW_IF_ERROR(
291
2
                create_texpr_literal_node<TYPE_DECIMAL32>(&storage, &node, precision, scale));
292
2
        break;
293
2
    }
294
2
    case TYPE_DECIMAL64: {
295
2
        const auto& storage =
296
2
                field.get<typename PrimitiveTypeTraits<TYPE_DECIMAL64>::NearestFieldType>()
297
2
                        .get_value();
298
2
        THROW_IF_ERROR(
299
2
                create_texpr_literal_node<TYPE_DECIMAL64>(&storage, &node, precision, scale));
300
2
        break;
301
2
    }
302
2
    case TYPE_DECIMAL128I: {
303
2
        const auto& storage =
304
2
                field.get<typename PrimitiveTypeTraits<TYPE_DECIMAL128I>::NearestFieldType>()
305
2
                        .get_value();
306
2
        THROW_IF_ERROR(
307
2
                create_texpr_literal_node<TYPE_DECIMAL128I>(&storage, &node, precision, scale));
308
2
        break;
309
2
    }
310
2
    case TYPE_DECIMAL256: {
311
2
        const auto& storage =
312
2
                field.get<typename PrimitiveTypeTraits<TYPE_DECIMAL256>::NearestFieldType>()
313
2
                        .get_value();
314
2
        THROW_IF_ERROR(
315
2
                create_texpr_literal_node<TYPE_DECIMAL256>(&storage, &node, precision, scale));
316
2
        break;
317
2
    }
318
2
    case TYPE_CHAR: {
319
0
        const auto& storage =
320
0
                field.get<typename PrimitiveTypeTraits<TYPE_CHAR>::NearestFieldType>();
321
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_CHAR>(&storage, &node));
322
0
        break;
323
0
    }
324
0
    case TYPE_VARCHAR: {
325
0
        const auto& storage =
326
0
                field.get<typename PrimitiveTypeTraits<TYPE_VARCHAR>::NearestFieldType>();
327
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_VARCHAR>(&storage, &node));
328
0
        break;
329
0
    }
330
1
    case TYPE_STRING: {
331
1
        const auto& storage =
332
1
                field.get<typename PrimitiveTypeTraits<TYPE_STRING>::NearestFieldType>();
333
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_STRING>(&storage, &node));
334
1
        break;
335
1
    }
336
1
    case TYPE_IPV4: {
337
0
        const auto& storage =
338
0
                field.get<typename PrimitiveTypeTraits<TYPE_IPV4>::NearestFieldType>();
339
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_IPV4>(&storage, &node));
340
0
        break;
341
0
    }
342
0
    case TYPE_IPV6: {
343
0
        const auto& storage =
344
0
                field.get<typename PrimitiveTypeTraits<TYPE_IPV6>::NearestFieldType>();
345
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_IPV6>(&storage, &node));
346
0
        break;
347
0
    }
348
1
    case TYPE_TIMEV2: {
349
1
        const auto& storage =
350
1
                field.get<typename PrimitiveTypeTraits<TYPE_TIMEV2>::NearestFieldType>();
351
1
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_TIMEV2>(&storage, &node));
352
1
        break;
353
1
    }
354
1
    case TYPE_VARBINARY: {
355
0
        const auto& svf = field.get<vectorized::StringViewField>();
356
0
        const std::string& storage = svf.get_string();
357
0
        THROW_IF_ERROR(create_texpr_literal_node<TYPE_VARBINARY>(&storage, &node));
358
0
        break;
359
0
    }
360
0
    default:
361
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "runtime filter meet invalid type {}",
362
0
                        int(type));
363
23
    }
364
23
    return node;
365
23
}
366
367
// NOLINTEND(readability-function-size)
368
// NOLINTEND(readability-function-cognitive-complexity)
369
} // namespace doris
370
371
namespace doris::vectorized {
372
373
0
bool VExpr::is_acting_on_a_slot(const VExpr& expr) {
374
0
    const auto& children = expr.children();
375
376
0
    auto is_a_slot = std::any_of(children.begin(), children.end(),
377
0
                                 [](const auto& child) { return is_acting_on_a_slot(*child); });
378
379
0
    return is_a_slot ? true
380
0
                     : (expr.node_type() == TExprNodeType::SLOT_REF ||
381
0
                        expr.node_type() == TExprNodeType::VIRTUAL_SLOT_REF);
382
0
}
383
384
VExpr::VExpr(const TExprNode& node)
385
400k
        : _node_type(node.node_type),
386
400k
          _opcode(node.__isset.opcode ? node.opcode : TExprOpcode::INVALID_OPCODE) {
387
400k
    if (node.__isset.fn) {
388
72
        _fn = node.fn;
389
72
    }
390
391
400k
    bool is_nullable = true;
392
400k
    if (node.__isset.is_nullable) {
393
396k
        is_nullable = node.is_nullable;
394
396k
    }
395
    // If we define null literal ,should make nullable data type to get correct field instead of undefined ptr
396
400k
    if (node.node_type == TExprNodeType::NULL_LITERAL) {
397
1
        CHECK(is_nullable);
398
1
    }
399
400k
    _data_type = get_data_type_with_default_argument(
400
400k
            DataTypeFactory::instance().create_data_type(node.type, is_nullable));
401
400k
}
402
403
0
VExpr::VExpr(const VExpr& vexpr) = default;
404
405
VExpr::VExpr(DataTypePtr type, bool is_slotref)
406
9
        : _opcode(TExprOpcode::INVALID_OPCODE),
407
9
          _data_type(get_data_type_with_default_argument(type)) {
408
9
    if (is_slotref) {
409
0
        _node_type = TExprNodeType::SLOT_REF;
410
0
    }
411
9
}
412
413
258k
Status VExpr::prepare(RuntimeState* state, const RowDescriptor& row_desc, VExprContext* context) {
414
258k
    ++context->_depth_num;
415
258k
    if (context->_depth_num > config::max_depth_of_expr_tree) {
416
0
        return Status::Error<ErrorCode::EXCEEDED_LIMIT>(
417
0
                "The depth of the expression tree is too big, make it less than {}",
418
0
                config::max_depth_of_expr_tree);
419
0
    }
420
421
258k
    for (auto& i : _children) {
422
232
        RETURN_IF_ERROR(i->prepare(state, row_desc, context));
423
232
    }
424
258k
    --context->_depth_num;
425
#ifndef BE_TEST
426
    _enable_inverted_index_query = state->query_options().enable_inverted_index_query;
427
#endif
428
258k
    return Status::OK();
429
258k
}
430
431
Status VExpr::open(RuntimeState* state, VExprContext* context,
432
512k
                   FunctionContext::FunctionStateScope scope) {
433
512k
    for (auto& i : _children) {
434
66
        RETURN_IF_ERROR(i->open(state, context, scope));
435
66
    }
436
512k
    if (scope == FunctionContext::FRAGMENT_LOCAL) {
437
258k
        RETURN_IF_ERROR(VExpr::get_const_col(context, nullptr));
438
258k
    }
439
512k
    return Status::OK();
440
512k
}
441
442
514k
void VExpr::close(VExprContext* context, FunctionContext::FunctionStateScope scope) {
443
514k
    for (auto& i : _children) {
444
291
        i->close(context, scope);
445
291
    }
446
514k
}
447
448
// NOLINTBEGIN(readability-function-size)
449
400k
Status VExpr::create_expr(const TExprNode& expr_node, VExprSPtr& expr) {
450
400k
    try {
451
400k
        switch (expr_node.node_type) {
452
0
        case TExprNodeType::BOOL_LITERAL:
453
31
        case TExprNodeType::INT_LITERAL:
454
31
        case TExprNodeType::LARGE_INT_LITERAL:
455
32
        case TExprNodeType::IPV4_LITERAL:
456
32
        case TExprNodeType::IPV6_LITERAL:
457
143
        case TExprNodeType::FLOAT_LITERAL:
458
144
        case TExprNodeType::DECIMAL_LITERAL:
459
147
        case TExprNodeType::DATE_LITERAL:
460
147
        case TExprNodeType::TIMEV2_LITERAL:
461
153
        case TExprNodeType::STRING_LITERAL:
462
153
        case TExprNodeType::JSON_LITERAL:
463
153
        case TExprNodeType::VARBINARY_LITERAL:
464
154
        case TExprNodeType::NULL_LITERAL: {
465
154
            expr = VLiteral::create_shared(expr_node);
466
154
            break;
467
153
        }
468
13
        case TExprNodeType::ARRAY_LITERAL: {
469
13
            expr = VArrayLiteral::create_shared(expr_node);
470
13
            break;
471
153
        }
472
0
        case TExprNodeType::MAP_LITERAL: {
473
0
            expr = VMapLiteral::create_shared(expr_node);
474
0
            break;
475
153
        }
476
0
        case TExprNodeType::STRUCT_LITERAL: {
477
0
            expr = VStructLiteral::create_shared(expr_node);
478
0
            break;
479
153
        }
480
400k
        case TExprNodeType::SLOT_REF: {
481
400k
            if (expr_node.slot_ref.__isset.is_virtual_slot && expr_node.slot_ref.is_virtual_slot) {
482
11
                expr = VirtualSlotRef::create_shared(expr_node);
483
11
                expr->_node_type = TExprNodeType::VIRTUAL_SLOT_REF;
484
400k
            } else {
485
400k
                expr = VSlotRef::create_shared(expr_node);
486
400k
            }
487
400k
            break;
488
153
        }
489
0
        case TExprNodeType::COLUMN_REF: {
490
0
            expr = VColumnRef::create_shared(expr_node);
491
0
            break;
492
153
        }
493
17
        case TExprNodeType::COMPOUND_PRED: {
494
17
            expr = VCompoundPred::create_shared(expr_node);
495
17
            break;
496
153
        }
497
0
        case TExprNodeType::LAMBDA_FUNCTION_EXPR: {
498
0
            expr = VLambdaFunctionExpr::create_shared(expr_node);
499
0
            break;
500
153
        }
501
0
        case TExprNodeType::LAMBDA_FUNCTION_CALL_EXPR: {
502
0
            expr = VLambdaFunctionCallExpr::create_shared(expr_node);
503
0
            break;
504
153
        }
505
0
        case TExprNodeType::ARITHMETIC_EXPR:
506
44
        case TExprNodeType::BINARY_PRED:
507
45
        case TExprNodeType::NULL_AWARE_BINARY_PRED:
508
45
        case TExprNodeType::COMPUTE_FUNCTION_CALL: {
509
45
            expr = VectorizedFnCall::create_shared(expr_node);
510
45
            break;
511
45
        }
512
21
        case TExprNodeType::FUNCTION_CALL: {
513
21
            if (expr_node.fn.name.function_name == "if") {
514
0
                expr = VectorizedIfExpr::create_shared(expr_node);
515
0
                break;
516
21
            } else if (expr_node.fn.name.function_name == "ifnull" ||
517
21
                       expr_node.fn.name.function_name == "nvl") {
518
0
                expr = VectorizedIfNullExpr::create_shared(expr_node);
519
0
                break;
520
21
            } else if (expr_node.fn.name.function_name == "coalesce") {
521
0
                expr = VectorizedCoalesceExpr::create_shared(expr_node);
522
0
                break;
523
0
            }
524
21
            expr = VectorizedFnCall::create_shared(expr_node);
525
21
            break;
526
21
        }
527
0
        case TExprNodeType::MATCH_PRED: {
528
0
            expr = VMatchPredicate::create_shared(expr_node);
529
0
            break;
530
21
        }
531
2
        case TExprNodeType::CAST_EXPR: {
532
2
            expr = VCastExpr::create_shared(expr_node);
533
2
            break;
534
21
        }
535
0
        case TExprNodeType::TRY_CAST_EXPR: {
536
0
            expr = TryCastExpr::create_shared(expr_node);
537
0
            break;
538
21
        }
539
5
        case TExprNodeType::IN_PRED: {
540
5
            expr = VInPredicate::create_shared(expr_node);
541
5
            break;
542
21
        }
543
0
        case TExprNodeType::CASE_EXPR: {
544
0
            if (!expr_node.__isset.case_expr) {
545
0
                return Status::InternalError("Case expression not set in thrift node");
546
0
            }
547
0
            expr = VCaseExpr::create_shared(expr_node);
548
0
            break;
549
0
        }
550
0
        case TExprNodeType::INFO_FUNC: {
551
0
            expr = VInfoFunc::create_shared(expr_node);
552
0
            break;
553
0
        }
554
0
        case TExprNodeType::SEARCH_EXPR: {
555
0
            expr = VSearchExpr::create_shared(expr_node);
556
0
            break;
557
0
        }
558
0
        default:
559
0
            return Status::InternalError("Unknown expr node type: {}", expr_node.node_type);
560
400k
        }
561
400k
    } catch (const Exception& e) {
562
0
        if (e.code() == ErrorCode::INTERNAL_ERROR) {
563
0
            return Status::InternalError("Create Expr failed because {}\nTExprNode={}", e.what(),
564
0
                                         apache::thrift::ThriftDebugString(expr_node));
565
0
        }
566
0
        return Status::Error<false>(e.code(), "Create Expr failed because {}", e.what());
567
0
        LOG(WARNING) << "create expr failed, TExprNode={}, reason={}"
568
0
                     << apache::thrift::ThriftDebugString(expr_node) << e.what();
569
0
    }
570
400k
    if (!expr->data_type()) {
571
0
        return Status::InvalidArgument("Unknown expr type: {}", expr_node.node_type);
572
0
    }
573
400k
    return Status::OK();
574
400k
}
575
// NOLINTEND(readability-function-size)
576
577
Status VExpr::create_tree_from_thrift(const std::vector<TExprNode>& nodes, int* node_idx,
578
400k
                                      VExprSPtr& root_expr, VExprContextSPtr& ctx) {
579
    // propagate error case
580
400k
    if (*node_idx >= nodes.size()) {
581
0
        return Status::InternalError("Failed to reconstruct expression tree from thrift.");
582
0
    }
583
584
    // create root expr
585
400k
    int root_children = nodes[*node_idx].num_children;
586
400k
    VExprSPtr root;
587
400k
    RETURN_IF_ERROR(create_expr(nodes[*node_idx], root));
588
400k
    DCHECK(root != nullptr);
589
400k
    root_expr = root;
590
400k
    ctx = std::make_shared<VExprContext>(root);
591
    // short path for leaf node
592
400k
    if (root_children <= 0) {
593
399k
        return Status::OK();
594
399k
    }
595
596
    // non-recursive traversal
597
46
    using VExprSPtrCountPair = std::pair<VExprSPtr, int>;
598
46
    std::stack<std::shared_ptr<VExprSPtrCountPair>> s;
599
46
    s.emplace(std::make_shared<VExprSPtrCountPair>(root, root_children));
600
313
    while (!s.empty()) {
601
        // copy the shared ptr resource to avoid dangling reference
602
267
        auto parent = s.top();
603
        // Decrement or pop
604
267
        if (parent->second > 1) {
605
173
            parent->second -= 1;
606
173
        } else {
607
94
            s.pop();
608
94
        }
609
610
267
        DCHECK(parent->first != nullptr);
611
267
        if (++*node_idx >= nodes.size()) {
612
0
            return Status::InternalError("Failed to reconstruct expression tree from thrift.");
613
0
        }
614
615
267
        VExprSPtr expr;
616
267
        RETURN_IF_ERROR(create_expr(nodes[*node_idx], expr));
617
267
        DCHECK(expr != nullptr);
618
267
        parent->first->add_child(expr);
619
        // push to stack if has children
620
267
        int num_children = nodes[*node_idx].num_children;
621
267
        if (num_children > 0) {
622
49
            s.emplace(std::make_shared<VExprSPtrCountPair>(expr, num_children));
623
49
        }
624
267
    }
625
46
    return Status::OK();
626
46
}
627
628
400k
Status VExpr::create_expr_tree(const TExpr& texpr, VExprContextSPtr& ctx) {
629
400k
    if (texpr.nodes.empty()) {
630
7
        ctx = nullptr;
631
7
        return Status::OK();
632
7
    }
633
400k
    int node_idx = 0;
634
400k
    VExprSPtr e;
635
400k
    Status status = create_tree_from_thrift(texpr.nodes, &node_idx, e, ctx);
636
400k
    if (status.ok() && node_idx + 1 != texpr.nodes.size()) {
637
0
        status = Status::InternalError(
638
0
                "Expression tree only partially reconstructed. Not all thrift nodes were "
639
0
                "used.");
640
0
    }
641
400k
    if (!status.ok()) {
642
0
        LOG(ERROR) << "Could not construct expr tree.\n"
643
0
                   << status << "\n"
644
0
                   << apache::thrift::ThriftDebugString(texpr);
645
0
    }
646
400k
    return status;
647
400k
}
648
649
28.1k
Status VExpr::create_expr_trees(const std::vector<TExpr>& texprs, VExprContextSPtrs& ctxs) {
650
28.1k
    ctxs.clear();
651
70.0k
    for (const auto& texpr : texprs) {
652
70.0k
        VExprContextSPtr ctx;
653
70.0k
        RETURN_IF_ERROR(create_expr_tree(texpr, ctx));
654
70.0k
        ctxs.push_back(ctx);
655
70.0k
    }
656
28.1k
    return Status::OK();
657
28.1k
}
658
659
Status VExpr::check_expr_output_type(const VExprContextSPtrs& ctxs,
660
24.0k
                                     const RowDescriptor& output_row_desc) {
661
24.0k
    if (ctxs.empty()) {
662
2
        return Status::OK();
663
2
    }
664
24.0k
    auto name_and_types = VectorizedUtils::create_name_and_data_types(output_row_desc);
665
24.0k
    if (ctxs.size() != name_and_types.size()) {
666
0
        return Status::InternalError(
667
0
                "output type size not match expr size {} , expected output size {} ", ctxs.size(),
668
0
                name_and_types.size());
669
0
    }
670
65.9k
    auto check_type_can_be_converted = [](DataTypePtr& from, DataTypePtr& to) -> bool {
671
65.9k
        if (to->equals(*from)) {
672
65.9k
            return true;
673
65.9k
        }
674
0
        if (to->is_nullable() && !from->is_nullable()) {
675
0
            return remove_nullable(to)->equals(*from);
676
0
        }
677
0
        return false;
678
0
    };
679
89.9k
    for (int i = 0; i < ctxs.size(); i++) {
680
65.9k
        auto real_expr_type = get_data_type_with_default_argument(ctxs[i]->root()->data_type());
681
65.9k
        auto&& [name, expected_type] = name_and_types[i];
682
65.9k
        if (!check_type_can_be_converted(real_expr_type, expected_type)) {
683
0
            return Status::InternalError(
684
0
                    "output type not match expr type, col name {} , expected type {} , real type "
685
0
                    "{}",
686
0
                    name, expected_type->get_name(), real_expr_type->get_name());
687
0
        }
688
65.9k
    }
689
24.0k
    return Status::OK();
690
24.0k
}
691
692
Status VExpr::prepare(const VExprContextSPtrs& ctxs, RuntimeState* state,
693
148k
                      const RowDescriptor& row_desc) {
694
258k
    for (auto ctx : ctxs) {
695
258k
        RETURN_IF_ERROR(ctx->prepare(state, row_desc));
696
258k
    }
697
148k
    return Status::OK();
698
148k
}
699
700
148k
Status VExpr::open(const VExprContextSPtrs& ctxs, RuntimeState* state) {
701
258k
    for (const auto& ctx : ctxs) {
702
258k
        RETURN_IF_ERROR(ctx->open(state));
703
258k
    }
704
148k
    return Status::OK();
705
148k
}
706
707
Status VExpr::clone_if_not_exists(const VExprContextSPtrs& ctxs, RuntimeState* state,
708
0
                                  VExprContextSPtrs& new_ctxs) {
709
0
    if (!new_ctxs.empty()) {
710
        // 'ctxs' was already cloned into '*new_ctxs', nothing to do.
711
0
        DCHECK_EQ(new_ctxs.size(), ctxs.size());
712
0
        for (auto& new_ctx : new_ctxs) {
713
0
            DCHECK(new_ctx->_is_clone);
714
0
        }
715
0
        return Status::OK();
716
0
    }
717
0
    new_ctxs.resize(ctxs.size());
718
0
    for (int i = 0; i < ctxs.size(); ++i) {
719
0
        RETURN_IF_ERROR(ctxs[i]->clone(state, new_ctxs[i]));
720
0
    }
721
0
    return Status::OK();
722
0
}
723
724
7
std::string VExpr::debug_string() const {
725
    // TODO: implement partial debug string for member vars
726
7
    std::stringstream out;
727
7
    out << " type=" << _data_type->get_name();
728
729
7
    if (!_children.empty()) {
730
0
        out << " children=" << debug_string(_children);
731
0
    }
732
733
7
    return out.str();
734
7
}
735
736
0
std::string VExpr::debug_string(const VExprSPtrs& exprs) {
737
0
    std::stringstream out;
738
0
    out << "[";
739
740
0
    for (int i = 0; i < exprs.size(); ++i) {
741
0
        out << (i == 0 ? "" : " ") << exprs[i]->debug_string();
742
0
    }
743
744
0
    out << "]";
745
0
    return out.str();
746
0
}
747
748
0
std::string VExpr::debug_string(const VExprContextSPtrs& ctxs) {
749
0
    VExprSPtrs exprs;
750
0
    for (const auto& ctx : ctxs) {
751
0
        exprs.push_back(ctx->root());
752
0
    }
753
0
    return debug_string(exprs);
754
0
}
755
756
530
bool VExpr::is_constant() const {
757
530
    return std::all_of(_children.begin(), _children.end(),
758
530
                       [](const VExprSPtr& expr) { return expr->is_constant(); });
759
530
}
760
761
Status VExpr::get_const_col(VExprContext* context,
762
258k
                            std::shared_ptr<ColumnPtrWrapper>* column_wrapper) {
763
258k
    if (!is_constant()) {
764
258k
        return Status::OK();
765
258k
    }
766
767
112
    if (_constant_col != nullptr) {
768
27
        DCHECK(column_wrapper != nullptr);
769
27
        *column_wrapper = _constant_col;
770
27
        return Status::OK();
771
27
    }
772
773
85
    ColumnPtr result;
774
85
    RETURN_IF_ERROR(execute_column(context, nullptr, 1, result));
775
85
    _constant_col = std::make_shared<ColumnPtrWrapper>(result);
776
85
    if (column_wrapper != nullptr) {
777
0
        *column_wrapper = _constant_col;
778
0
    }
779
780
85
    return Status::OK();
781
85
}
782
783
79
void VExpr::register_function_context(RuntimeState* state, VExprContext* context) {
784
79
    std::vector<DataTypePtr> arg_types;
785
156
    for (auto& i : _children) {
786
156
        arg_types.push_back(i->data_type());
787
156
    }
788
789
79
    _fn_context_index = context->register_function_context(state, _data_type, arg_types);
790
79
}
791
792
Status VExpr::init_function_context(RuntimeState* state, VExprContext* context,
793
                                    FunctionContext::FunctionStateScope scope,
794
39
                                    const FunctionBasePtr& function) const {
795
39
    FunctionContext* fn_ctx = context->fn_context(_fn_context_index);
796
39
    if (scope == FunctionContext::FRAGMENT_LOCAL) {
797
27
        std::vector<std::shared_ptr<ColumnPtrWrapper>> constant_cols;
798
52
        for (auto c : _children) {
799
52
            std::shared_ptr<ColumnPtrWrapper> const_col;
800
52
            RETURN_IF_ERROR(c->get_const_col(context, &const_col));
801
52
            constant_cols.push_back(const_col);
802
52
        }
803
27
        fn_ctx->set_constant_cols(constant_cols);
804
27
    }
805
806
39
    if (scope == FunctionContext::FRAGMENT_LOCAL) {
807
27
        RETURN_IF_ERROR(function->open(fn_ctx, FunctionContext::FRAGMENT_LOCAL));
808
27
    }
809
39
    RETURN_IF_ERROR(function->open(fn_ctx, FunctionContext::THREAD_LOCAL));
810
39
    return Status::OK();
811
39
}
812
813
void VExpr::close_function_context(VExprContext* context, FunctionContext::FunctionStateScope scope,
814
157
                                   const FunctionBasePtr& function) const {
815
157
    if (_fn_context_index != -1) {
816
41
        FunctionContext* fn_ctx = context->fn_context(_fn_context_index);
817
        // `close_function_context` is called in VExprContext's destructor so do not throw exceptions here.
818
41
        static_cast<void>(function->close(fn_ctx, FunctionContext::THREAD_LOCAL));
819
41
        if (scope == FunctionContext::FRAGMENT_LOCAL) {
820
29
            static_cast<void>(function->close(fn_ctx, FunctionContext::FRAGMENT_LOCAL));
821
29
        }
822
41
    }
823
157
}
824
825
0
Status VExpr::check_constant(const Block& block, ColumnNumbers arguments) const {
826
0
    if (is_constant() && !VectorizedUtils::all_arguments_are_constant(block, arguments)) {
827
0
        return Status::InternalError("const check failed, expr={}", debug_string());
828
0
    }
829
0
    return Status::OK();
830
0
}
831
832
0
uint64_t VExpr::get_digest(uint64_t seed) const {
833
0
    auto digest = seed;
834
0
    for (auto child : _children) {
835
0
        digest = child->get_digest(digest);
836
0
        if (digest == 0) {
837
0
            return 0;
838
0
        }
839
0
    }
840
841
0
    auto& fn_name = _fn.name.function_name;
842
0
    if (!fn_name.empty()) {
843
0
        digest = HashUtil::hash64(fn_name.c_str(), fn_name.size(), digest);
844
0
    } else {
845
0
        digest = HashUtil::hash64((const char*)&_node_type, sizeof(_node_type), digest);
846
0
        digest = HashUtil::hash64((const char*)&_opcode, sizeof(_opcode), digest);
847
0
    }
848
0
    return digest;
849
0
}
850
851
0
ColumnPtr VExpr::get_result_from_const(size_t count) const {
852
0
    return ColumnConst::create(_constant_col->column_ptr, count);
853
0
}
854
855
Status VExpr::_evaluate_inverted_index(VExprContext* context, const FunctionBasePtr& function,
856
1
                                       uint32_t segment_num_rows) {
857
    // Pre-allocate vectors based on an estimated or known size
858
1
    std::vector<segment_v2::IndexIterator*> iterators;
859
1
    std::vector<vectorized::IndexFieldNameAndTypePair> data_type_with_names;
860
1
    std::vector<int> column_ids;
861
1
    vectorized::ColumnsWithTypeAndName arguments;
862
1
    VExprSPtrs children_exprs;
863
864
    // Reserve space to avoid multiple reallocations
865
1
    const size_t estimated_size = get_num_children();
866
1
    iterators.reserve(estimated_size);
867
1
    data_type_with_names.reserve(estimated_size);
868
1
    column_ids.reserve(estimated_size);
869
1
    children_exprs.reserve(estimated_size);
870
871
1
    auto index_context = context->get_index_context();
872
873
    // if child is cast expr, we need to ensure target data type is the same with storage data type.
874
    // or they are all string type
875
    // and if data type is array, we need to get the nested data type to ensure that.
876
2
    for (const auto& child : children()) {
877
2
        if (child->node_type() == TExprNodeType::CAST_EXPR) {
878
1
            auto* cast_expr = assert_cast<VCastExpr*>(child.get());
879
1
            DCHECK_EQ(cast_expr->get_num_children(), 1);
880
1
            if (cast_expr->get_child(0)->is_slot_ref()) {
881
0
                auto* column_slot_ref = assert_cast<VSlotRef*>(cast_expr->get_child(0).get());
882
0
                auto column_id = column_slot_ref->column_id();
883
0
                const auto* storage_name_type =
884
0
                        context->get_index_context()->get_storage_name_and_type_by_column_id(
885
0
                                column_id);
886
0
                auto storage_type = remove_nullable(storage_name_type->second);
887
0
                auto target_type = remove_nullable(cast_expr->get_target_type());
888
0
                auto origin_primitive_type = storage_type->get_primitive_type();
889
0
                auto target_primitive_type = target_type->get_primitive_type();
890
0
                if (is_complex_type(storage_type->get_primitive_type())) {
891
0
                    if (storage_type->get_primitive_type() == TYPE_ARRAY &&
892
0
                        target_type->get_primitive_type() == TYPE_ARRAY) {
893
0
                        auto nested_storage_type =
894
0
                                (assert_cast<const DataTypeArray*>(storage_type.get()))
895
0
                                        ->get_nested_type();
896
0
                        origin_primitive_type = nested_storage_type->get_primitive_type();
897
0
                        auto nested_target_type =
898
0
                                (assert_cast<const DataTypeArray*>(target_type.get()))
899
0
                                        ->get_nested_type();
900
0
                        target_primitive_type = nested_target_type->get_primitive_type();
901
0
                    } else {
902
0
                        continue;
903
0
                    }
904
0
                }
905
0
                if (origin_primitive_type != TYPE_VARIANT &&
906
0
                    (storage_type->equals(*target_type) ||
907
0
                     (is_string_type(target_primitive_type) &&
908
0
                      is_string_type(origin_primitive_type)))) {
909
0
                    children_exprs.emplace_back(expr_without_cast(child));
910
0
                }
911
1
            } else {
912
1
                return Status::OK(); // for example: cast("abc") as ipv4 case
913
1
            }
914
1
        } else {
915
1
            children_exprs.emplace_back(child);
916
1
        }
917
2
    }
918
919
0
    if (children_exprs.empty()) {
920
0
        return Status::OK(); // Early exit if no children to process
921
0
    }
922
923
0
    for (const auto& child : children_exprs) {
924
0
        if (child->is_slot_ref()) {
925
0
            auto* column_slot_ref = assert_cast<VSlotRef*>(child.get());
926
0
            auto column_id = column_slot_ref->column_id();
927
0
            auto* iter = context->get_index_context()->get_inverted_index_iterator_by_column_id(
928
0
                    column_id);
929
            //column does not have inverted index
930
0
            if (iter == nullptr) {
931
0
                continue;
932
0
            }
933
0
            const auto* storage_name_type =
934
0
                    context->get_index_context()->get_storage_name_and_type_by_column_id(column_id);
935
0
            if (storage_name_type == nullptr) {
936
0
                auto err_msg = fmt::format(
937
0
                        "storage_name_type cannot be found for column {} while in {} "
938
0
                        "evaluate_inverted_index",
939
0
                        column_id, expr_name());
940
0
                LOG(ERROR) << err_msg;
941
0
                return Status::InternalError(err_msg);
942
0
            }
943
0
            iterators.emplace_back(iter);
944
0
            data_type_with_names.emplace_back(*storage_name_type);
945
0
            column_ids.emplace_back(column_id);
946
0
        } else if (child->is_literal()) {
947
0
            auto* column_literal = assert_cast<VLiteral*>(child.get());
948
0
            arguments.emplace_back(column_literal->get_column_ptr(),
949
0
                                   column_literal->get_data_type(), column_literal->expr_name());
950
0
        } else if (child->can_push_down_to_index()) {
951
0
            RETURN_IF_ERROR(child->evaluate_inverted_index(context, segment_num_rows));
952
0
        } else {
953
0
            return Status::OK(); // others cases
954
0
        }
955
0
    }
956
957
    // is null or is not null has no arguments
958
0
    if (iterators.empty() || (arguments.empty() && !(function->get_name() == "is_not_null_pred" ||
959
0
                                                     function->get_name() == "is_null_pred"))) {
960
0
        return Status::OK(); // Nothing to evaluate or no literals to compare against
961
0
    }
962
963
0
    const InvertedIndexAnalyzerCtx* analyzer_ctx = nullptr;
964
0
    if (auto index_ctx = context->get_index_context(); index_ctx != nullptr) {
965
0
        analyzer_ctx = index_ctx->get_analyzer_ctx_for_expr(this);
966
0
    }
967
968
0
    auto result_bitmap = segment_v2::InvertedIndexResultBitmap();
969
0
    auto res = function->evaluate_inverted_index(arguments, data_type_with_names, iterators,
970
0
                                                 segment_num_rows, analyzer_ctx, result_bitmap);
971
0
    if (!res.ok()) {
972
0
        return res;
973
0
    }
974
0
    if (!result_bitmap.is_empty()) {
975
0
        index_context->set_index_result_for_expr(this, result_bitmap);
976
0
        for (int column_id : column_ids) {
977
0
            index_context->set_true_for_index_status(this, column_id);
978
0
        }
979
0
    }
980
0
    return Status::OK();
981
0
}
982
983
0
size_t VExpr::estimate_memory(const size_t rows) {
984
0
    if (is_const_and_have_executed()) {
985
0
        return 0;
986
0
    }
987
988
0
    size_t estimate_size = 0;
989
0
    for (auto& child : _children) {
990
0
        estimate_size += child->estimate_memory(rows);
991
0
    }
992
993
0
    if (_data_type->have_maximum_size_of_value()) {
994
0
        estimate_size += rows * _data_type->get_size_of_value_in_memory();
995
0
    } else {
996
0
        estimate_size += rows * 64; /// TODO: need a more reasonable value
997
0
    }
998
0
    return estimate_size;
999
0
}
1000
1001
11
bool VExpr::fast_execute(VExprContext* context, ColumnPtr& result_column) const {
1002
11
    if (context->get_index_context() &&
1003
11
        context->get_index_context()->get_index_result_column().contains(this)) {
1004
        // prepare a column to save result
1005
1
        result_column = context->get_index_context()->get_index_result_column()[this];
1006
1
        if (_data_type->is_nullable()) {
1007
1
            result_column = make_nullable(result_column);
1008
1
        }
1009
1
        return true;
1010
1
    }
1011
10
    return false;
1012
11
}
1013
1014
0
bool VExpr::equals(const VExpr& other) {
1015
0
    return false;
1016
0
}
1017
1018
Status VExpr::evaluate_ann_range_search(
1019
        const segment_v2::AnnRangeSearchRuntime& runtime,
1020
        const std::vector<std::unique_ptr<segment_v2::IndexIterator>>& index_iterators,
1021
        const std::vector<ColumnId>& idx_to_cid,
1022
        const std::vector<std::unique_ptr<segment_v2::ColumnIterator>>& column_iterators,
1023
0
        roaring::Roaring& row_bitmap, AnnIndexStats& ann_index_stats) {
1024
0
    return Status::OK();
1025
0
}
1026
1027
void VExpr::prepare_ann_range_search(const doris::VectorSearchUserParams& params,
1028
                                     segment_v2::AnnRangeSearchRuntime& range_search_runtime,
1029
0
                                     bool& suitable_for_ann_index) {
1030
0
    if (!suitable_for_ann_index) {
1031
0
        return;
1032
0
    }
1033
0
    for (auto& child : _children) {
1034
0
        child->prepare_ann_range_search(params, range_search_runtime, suitable_for_ann_index);
1035
0
        if (!suitable_for_ann_index) {
1036
0
            return;
1037
0
        }
1038
0
    }
1039
0
}
1040
1041
2
bool VExpr::ann_range_search_executedd() {
1042
2
    return _has_been_executed;
1043
2
}
1044
1045
2
bool VExpr::ann_dist_is_fulfilled() const {
1046
2
    return _virtual_column_is_fulfilled;
1047
2
}
1048
1049
#include "common/compile_check_end.h"
1050
} // namespace doris::vectorized