Coverage Report

Created: 2024-11-20 12:56

/root/doris/be/src/vec/functions/if.cpp
Line
Count
Source (jump to first uncovered line)
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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/If.cpp
19
// and modified by Doris
20
21
#include <glog/logging.h>
22
#include <stddef.h>
23
24
#include <algorithm>
25
#include <boost/iterator/iterator_facade.hpp>
26
#include <memory>
27
#include <ostream>
28
#include <type_traits>
29
#include <utility>
30
31
#include "common/status.h"
32
#include "vec/aggregate_functions/aggregate_function.h"
33
#include "vec/columns/column.h"
34
#include "vec/columns/column_const.h"
35
#include "vec/columns/column_nullable.h"
36
#include "vec/columns/column_vector.h"
37
#include "vec/columns/columns_number.h"
38
#include "vec/common/assert_cast.h"
39
#include "vec/common/pod_array_fwd.h"
40
#include "vec/common/typeid_cast.h"
41
#include "vec/core/block.h"
42
#include "vec/core/call_on_type_index.h"
43
#include "vec/core/column_numbers.h"
44
#include "vec/core/column_with_type_and_name.h"
45
#include "vec/core/types.h"
46
#include "vec/data_types/data_type.h"
47
#include "vec/data_types/data_type_nullable.h"
48
#include "vec/data_types/data_type_number.h"
49
#include "vec/data_types/get_least_supertype.h"
50
#include "vec/functions/function.h"
51
#include "vec/functions/function_helpers.h"
52
#include "vec/functions/simple_function_factory.h"
53
54
namespace doris {
55
class FunctionContext;
56
57
namespace vectorized {
58
namespace NumberTraits {
59
struct Error;
60
} // namespace NumberTraits
61
} // namespace vectorized
62
} // namespace doris
63
64
namespace doris::vectorized {
65
66
template <typename A, typename B, typename ResultType>
67
struct NumIfImpl {
68
    using ArrayCond = PaddedPODArray<UInt8>;
69
    using ArrayA = PaddedPODArray<A>;
70
    using ArrayB = PaddedPODArray<B>;
71
    using ColVecResult = ColumnVector<ResultType>;
72
73
    static void vector_vector(const ArrayCond& cond, const ArrayA& a, const ArrayB& b, Block& block,
74
3
                              size_t result, UInt32) {
75
3
        size_t size = cond.size();
76
3
        auto col_res = ColVecResult::create(size);
77
3
        typename ColVecResult::Container& res = col_res->get_data();
78
79
12
        for (size_t i = 0; i < size; ++i)
80
9
            res[i] = cond[i] ? static_cast<ResultType>(a[i]) : static_cast<ResultType>(b[i]);
81
3
        block.replace_by_position(result, std::move(col_res));
82
3
    }
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIhhhE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEES8_S8_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplItttE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_ItLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIjjjE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IjLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplImmmE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_ImLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIaaaE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IaLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIsssE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IsLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
_ZN5doris10vectorized9NumIfImplIiiiE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IiLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Line
Count
Source
74
2
                              size_t result, UInt32) {
75
2
        size_t size = cond.size();
76
2
        auto col_res = ColVecResult::create(size);
77
2
        typename ColVecResult::Container& res = col_res->get_data();
78
79
8
        for (size_t i = 0; i < size; ++i)
80
6
            res[i] = cond[i] ? static_cast<ResultType>(a[i]) : static_cast<ResultType>(b[i]);
81
2
        block.replace_by_position(result, std::move(col_res));
82
2
    }
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIlllE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IlLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplInnnE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_InLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIfffE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IfLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
_ZN5doris10vectorized9NumIfImplIdddE13vector_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IdLm4096ES5_Lm15ELm16EEESB_RNS0_5BlockEmj
Line
Count
Source
74
1
                              size_t result, UInt32) {
75
1
        size_t size = cond.size();
76
1
        auto col_res = ColVecResult::create(size);
77
1
        typename ColVecResult::Container& res = col_res->get_data();
78
79
4
        for (size_t i = 0; i < size; ++i)
80
3
            res[i] = cond[i] ? static_cast<ResultType>(a[i]) : static_cast<ResultType>(b[i]);
81
1
        block.replace_by_position(result, std::move(col_res));
82
1
    }
83
84
    static void vector_constant(const ArrayCond& cond, const ArrayA& a, B b, Block& block,
85
0
                                size_t result, UInt32) {
86
0
        size_t size = cond.size();
87
0
        auto col_res = ColVecResult::create(size);
88
0
        typename ColVecResult::Container& res = col_res->get_data();
89
90
0
        for (size_t i = 0; i < size; ++i)
91
0
            res[i] = cond[i] ? static_cast<ResultType>(a[i]) : static_cast<ResultType>(b);
92
0
        block.replace_by_position(result, std::move(col_res));
93
0
    }
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIhhhE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEES8_hRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplItttE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_ItLm4096ES5_Lm15ELm16EEEtRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIjjjE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IjLm4096ES5_Lm15ELm16EEEjRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplImmmE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_ImLm4096ES5_Lm15ELm16EEEmRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIaaaE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IaLm4096ES5_Lm15ELm16EEEaRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIsssE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IsLm4096ES5_Lm15ELm16EEEsRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIiiiE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IiLm4096ES5_Lm15ELm16EEEiRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIlllE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IlLm4096ES5_Lm15ELm16EEElRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplInnnE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_InLm4096ES5_Lm15ELm16EEEnRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIfffE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IfLm4096ES5_Lm15ELm16EEEfRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIdddE15vector_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEERKNS3_IdLm4096ES5_Lm15ELm16EEEdRNS0_5BlockEmj
94
95
    static void constant_vector(const ArrayCond& cond, A a, const ArrayB& b, Block& block,
96
0
                                size_t result, UInt32) {
97
0
        size_t size = cond.size();
98
0
        auto col_res = ColVecResult::create(size);
99
0
        typename ColVecResult::Container& res = col_res->get_data();
100
101
0
        for (size_t i = 0; i < size; ++i)
102
0
            res[i] = cond[i] ? static_cast<ResultType>(a) : static_cast<ResultType>(b[i]);
103
0
        block.replace_by_position(result, std::move(col_res));
104
0
    }
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIhhhE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEhS8_RNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplItttE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEtRKNS3_ItLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIjjjE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEjRKNS3_IjLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplImmmE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEmRKNS3_ImLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIaaaE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEaRKNS3_IaLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIsssE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEsRKNS3_IsLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIiiiE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEiRKNS3_IiLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIlllE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEElRKNS3_IlLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplInnnE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEnRKNS3_InLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIfffE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEfRKNS3_IfLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIdddE15constant_vectorERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEdRKNS3_IdLm4096ES5_Lm15ELm16EEERNS0_5BlockEmj
105
106
    static void constant_constant(const ArrayCond& cond, A a, B b, Block& block, size_t result,
107
0
                                  UInt32) {
108
0
        size_t size = cond.size();
109
0
        auto col_res = ColVecResult::create(size);
110
0
        typename ColVecResult::Container& res = col_res->get_data();
111
112
0
        for (size_t i = 0; i < size; ++i)
113
0
            res[i] = cond[i] ? static_cast<ResultType>(a) : static_cast<ResultType>(b);
114
0
        block.replace_by_position(result, std::move(col_res));
115
0
    }
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIhhhE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEhhRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplItttE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEttRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIjjjE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEjjRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplImmmE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEmmRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIaaaE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEaaRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIsssE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEssRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIiiiE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEiiRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIlllE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEllRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplInnnE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEnnRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIfffE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEffRNS0_5BlockEmj
Unexecuted instantiation: _ZN5doris10vectorized9NumIfImplIdddE17constant_constantERKNS0_8PODArrayIhLm4096E9AllocatorILb0ELb0ELb0EELm15ELm16EEEddRNS0_5BlockEmj
116
};
117
118
template <typename A, typename B>
119
struct NumIfImpl<A, B, NumberTraits::Error> {
120
private:
121
    [[noreturn]] static void throw_error() {
122
        LOG(FATAL) << "Internal logic error: invalid types of arguments 2 and 3 of if";
123
    }
124
125
public:
126
    template <typename... Args>
127
    static void vector_vector(Args&&...) {
128
        throw_error();
129
    }
130
    template <typename... Args>
131
    static void vector_constant(Args&&...) {
132
        throw_error();
133
    }
134
    template <typename... Args>
135
    static void constant_vector(Args&&...) {
136
        throw_error();
137
    }
138
    template <typename... Args>
139
    static void constant_constant(Args&&...) {
140
        throw_error();
141
    }
142
};
143
144
// todo(wb) support llvm codegen
145
class FunctionIf : public IFunction {
146
public:
147
    static constexpr auto name = "if";
148
149
9
    static FunctionPtr create() { return std::make_shared<FunctionIf>(); }
150
0
    String get_name() const override { return name; }
151
152
8
    size_t get_number_of_arguments() const override { return 3; }
153
16
    bool use_default_implementation_for_nulls() const override { return false; }
154
    ColumnNumbers get_arguments_that_dont_imply_nullable_return_type(
155
0
            size_t /*number_of_arguments*/) const override {
156
0
        return {0};
157
0
    }
158
159
8
    DataTypePtr get_return_type_impl(const DataTypes& arguments) const override {
160
        // if return type is custom, one of nullable return type will be nullable
161
8
        bool nullable = arguments[1]->is_nullable() || arguments[2]->is_nullable();
162
8
        if (nullable) {
163
8
            return make_nullable(arguments[1]);
164
8
        } else {
165
0
            return arguments[1];
166
0
        }
167
8
    }
168
169
31
    static ColumnPtr materialize_column_if_const(const ColumnPtr& column) {
170
31
        return column->convert_to_full_column_if_const();
171
31
    }
172
173
0
    static ColumnPtr make_nullable_column_if_not(const ColumnPtr& column) {
174
0
        if (is_column_nullable(*column)) return column;
175
176
0
        return ColumnNullable::create(materialize_column_if_const(column),
177
0
                                      ColumnUInt8::create(column->size(), 0));
178
0
    }
179
180
10
    static ColumnPtr get_nested_column(const ColumnPtr& column) {
181
10
        if (auto* nullable = check_and_get_column<ColumnNullable>(*column))
182
10
            return nullable->get_nested_column_ptr();
183
0
        else if (const auto* column_const = check_and_get_column<ColumnConst>(*column))
184
0
            return ColumnConst::create(get_nested_column(column_const->get_data_column_ptr()),
185
0
                                       column->size());
186
187
0
        return column;
188
10
    }
189
190
    Status execute_generic(Block& block, const ColumnUInt8* cond_col,
191
                           const ColumnWithTypeAndName& then_col_type_name,
192
                           const ColumnWithTypeAndName& else_col_type_name, size_t result,
193
7
                           size_t input_row_count) {
194
7
        MutableColumnPtr result_column = block.get_by_position(result).type->create_column();
195
7
        result_column->reserve(input_row_count);
196
197
7
        const IColumn& then_col = *then_col_type_name.column;
198
7
        const IColumn& else_col = *else_col_type_name.column;
199
7
        bool then_is_const = is_column_const(then_col);
200
7
        bool else_is_const = is_column_const(else_col);
201
202
7
        const auto& cond_array = cond_col->get_data();
203
204
7
        if (then_is_const && else_is_const) {
205
0
            const IColumn& then_nested_column =
206
0
                    assert_cast<const ColumnConst&>(then_col).get_data_column();
207
0
            const IColumn& else_nested_column =
208
0
                    assert_cast<const ColumnConst&>(else_col).get_data_column();
209
0
            for (size_t i = 0; i < input_row_count; i++) {
210
0
                if (cond_array[i])
211
0
                    result_column->insert_from(then_nested_column, 0);
212
0
                else
213
0
                    result_column->insert_from(else_nested_column, 0);
214
0
            }
215
7
        } else if (then_is_const) {
216
0
            const IColumn& then_nested_column =
217
0
                    assert_cast<const ColumnConst&>(then_col).get_data_column();
218
219
0
            for (size_t i = 0; i < input_row_count; i++) {
220
0
                if (cond_array[i])
221
0
                    result_column->insert_from(then_nested_column, 0);
222
0
                else
223
0
                    result_column->insert_from(else_col, i);
224
0
            }
225
7
        } else if (else_is_const) {
226
0
            const IColumn& else_nested_column =
227
0
                    assert_cast<const ColumnConst&>(else_col).get_data_column();
228
229
0
            for (size_t i = 0; i < input_row_count; i++) {
230
0
                if (cond_array[i])
231
0
                    result_column->insert_from(then_col, i);
232
0
                else
233
0
                    result_column->insert_from(else_nested_column, 0);
234
0
            }
235
7
        } else {
236
26
            for (size_t i = 0; i < input_row_count; i++) {
237
19
                result_column->insert_from(cond_array[i] ? then_col : else_col, i);
238
19
            }
239
7
        }
240
7
        block.replace_by_position(result, std::move(result_column));
241
7
        return Status::OK();
242
7
    }
243
244
    void execute_basic_type(Block& block, const ColumnUInt8* cond_col,
245
                            const ColumnWithTypeAndName& then_col,
246
3
                            const ColumnWithTypeAndName& else_col, size_t result, Status& status) {
247
3
        auto call = [&](const auto& types) -> bool {
248
3
            using Types = std::decay_t<decltype(types)>;
249
3
            using T0 = typename Types::LeftType;
250
3
            using result_type = typename Types::LeftType;
251
252
            // for doris, args type and return type must be sanme beacause of type cast has already done before, so here just need one type;
253
            // but code still need a better impelement
254
3
            using ColVecT0 = ColumnVector<T0>;
255
256
3
            if (auto col_then = check_and_get_column<ColVecT0>(then_col.column.get())) {
257
3
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
258
3
                    NumIfImpl<T0, T0, result_type>::vector_vector(
259
3
                            cond_col->get_data(), col_then->get_data(), col_else->get_data(), block,
260
3
                            result, 0);
261
3
                } else if (auto col_const_else =
262
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
263
0
                    NumIfImpl<T0, T0, result_type>::vector_constant(
264
0
                            cond_col->get_data(), col_then->get_data(),
265
0
                            col_const_else->template get_value<T0>(), block, result, 0);
266
0
                }
267
3
            } else if (auto col_const_then =
268
0
                               check_and_get_column_const<ColVecT0>(then_col.column.get())) {
269
0
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
270
0
                    NumIfImpl<T0, T0, result_type>::constant_vector(
271
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
272
0
                            col_else->get_data(), block, result, 0);
273
0
                } else if (auto col_const_else =
274
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
275
0
                    NumIfImpl<T0, T0, result_type>::constant_constant(
276
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
277
0
                            col_const_else->template get_value<T0>(), block, result, 0);
278
0
                }
279
0
            } else {
280
0
                status = Status::InternalError("unexpected args column type");
281
0
            }
282
3
            return true;
283
3
        };
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhtEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIhdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIthEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIttEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairItdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjtEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIjdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImtEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairImdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIahEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIatEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIajEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIamEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIaaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIasEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIaiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIalEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIanEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIafEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIadEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIshEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIstEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIssEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIslEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIsdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIihEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIitEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIijEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIimEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIiaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIisEEEEbSF_
_ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIiiEEEEbSF_
Line
Count
Source
247
2
        auto call = [&](const auto& types) -> bool {
248
2
            using Types = std::decay_t<decltype(types)>;
249
2
            using T0 = typename Types::LeftType;
250
2
            using result_type = typename Types::LeftType;
251
252
            // for doris, args type and return type must be sanme beacause of type cast has already done before, so here just need one type;
253
            // but code still need a better impelement
254
2
            using ColVecT0 = ColumnVector<T0>;
255
256
2
            if (auto col_then = check_and_get_column<ColVecT0>(then_col.column.get())) {
257
2
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
258
2
                    NumIfImpl<T0, T0, result_type>::vector_vector(
259
2
                            cond_col->get_data(), col_then->get_data(), col_else->get_data(), block,
260
2
                            result, 0);
261
2
                } else if (auto col_const_else =
262
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
263
0
                    NumIfImpl<T0, T0, result_type>::vector_constant(
264
0
                            cond_col->get_data(), col_then->get_data(),
265
0
                            col_const_else->template get_value<T0>(), block, result, 0);
266
0
                }
267
2
            } else if (auto col_const_then =
268
0
                               check_and_get_column_const<ColVecT0>(then_col.column.get())) {
269
0
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
270
0
                    NumIfImpl<T0, T0, result_type>::constant_vector(
271
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
272
0
                            col_else->get_data(), block, result, 0);
273
0
                } else if (auto col_const_else =
274
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
275
0
                    NumIfImpl<T0, T0, result_type>::constant_constant(
276
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
277
0
                            col_const_else->template get_value<T0>(), block, result, 0);
278
0
                }
279
0
            } else {
280
0
                status = Status::InternalError("unexpected args column type");
281
0
            }
282
2
            return true;
283
2
        };
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIilEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIinEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIifEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIidEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIltEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIljEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIliEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIllEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIlfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIldEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIntEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIniEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairInfEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIndEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIftEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIflEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIffEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIfdEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdhEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdtEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdjEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdmEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdaEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdsEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdiEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdlEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdnEEEEbSF_
Unexecuted instantiation: _ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIdfEEEEbSF_
_ZZN5doris10vectorized10FunctionIf18execute_basic_typeERNS0_5BlockEPKNS0_12ColumnVectorIhEERKNS0_21ColumnWithTypeAndNameESA_mRNS_6StatusEENKUlRKT_E_clINS0_8TypePairIddEEEEbSF_
Line
Count
Source
247
1
        auto call = [&](const auto& types) -> bool {
248
1
            using Types = std::decay_t<decltype(types)>;
249
1
            using T0 = typename Types::LeftType;
250
1
            using result_type = typename Types::LeftType;
251
252
            // for doris, args type and return type must be sanme beacause of type cast has already done before, so here just need one type;
253
            // but code still need a better impelement
254
1
            using ColVecT0 = ColumnVector<T0>;
255
256
1
            if (auto col_then = check_and_get_column<ColVecT0>(then_col.column.get())) {
257
1
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
258
1
                    NumIfImpl<T0, T0, result_type>::vector_vector(
259
1
                            cond_col->get_data(), col_then->get_data(), col_else->get_data(), block,
260
1
                            result, 0);
261
1
                } else if (auto col_const_else =
262
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
263
0
                    NumIfImpl<T0, T0, result_type>::vector_constant(
264
0
                            cond_col->get_data(), col_then->get_data(),
265
0
                            col_const_else->template get_value<T0>(), block, result, 0);
266
0
                }
267
1
            } else if (auto col_const_then =
268
0
                               check_and_get_column_const<ColVecT0>(then_col.column.get())) {
269
0
                if (auto col_else = check_and_get_column<ColVecT0>(else_col.column.get())) {
270
0
                    NumIfImpl<T0, T0, result_type>::constant_vector(
271
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
272
0
                            col_else->get_data(), block, result, 0);
273
0
                } else if (auto col_const_else =
274
0
                                   check_and_get_column_const<ColVecT0>(else_col.column.get())) {
275
0
                    NumIfImpl<T0, T0, result_type>::constant_constant(
276
0
                            cond_col->get_data(), col_const_then->template get_value<T0>(),
277
0
                            col_const_else->template get_value<T0>(), block, result, 0);
278
0
                }
279
0
            } else {
280
0
                status = Status::InternalError("unexpected args column type");
281
0
            }
282
1
            return true;
283
1
        };
284
285
        // todo(wb): a better way to determine type
286
3
        call_on_basic_types<true, true, false, false>(then_col.type->get_type_id(),
287
3
                                                      else_col.type->get_type_id(), call);
288
3
    }
289
290
    Status execute_for_null_then_else(FunctionContext* context, Block& block,
291
                                      const ColumnWithTypeAndName& arg_cond,
292
                                      const ColumnWithTypeAndName& arg_then,
293
                                      const ColumnWithTypeAndName& arg_else, size_t result,
294
18
                                      size_t input_rows_count, bool& handled) {
295
18
        bool then_is_null = arg_then.column->only_null();
296
18
        bool else_is_null = arg_else.column->only_null();
297
298
18
        if (!then_is_null && !else_is_null) {
299
15
            return Status::OK();
300
15
        }
301
302
3
        if (then_is_null && else_is_null) {
303
0
            block.get_by_position(result).column =
304
0
                    block.get_by_position(result).type->create_column_const_with_default_value(
305
0
                            input_rows_count);
306
0
            handled = true;
307
0
            return Status::OK();
308
0
        }
309
310
3
        const ColumnUInt8* cond_col = typeid_cast<const ColumnUInt8*>(arg_cond.column.get());
311
3
        const ColumnConst* cond_const_col =
312
3
                check_and_get_column_const<ColumnVector<UInt8>>(arg_cond.column.get());
313
314
        /// If then is NULL, we create Nullable column with null mask OR-ed with condition.
315
3
        if (then_is_null) {
316
3
            if (cond_col) {
317
3
                if (is_column_nullable(*arg_else.column)) { // if(cond, null, nullable)
318
3
                    auto arg_else_column = arg_else.column;
319
3
                    auto result_column = (*std::move(arg_else_column)).mutate();
320
3
                    assert_cast<ColumnNullable&>(*result_column)
321
3
                            .apply_null_map(assert_cast<const ColumnUInt8&>(*arg_cond.column));
322
3
                    block.replace_by_position(result, std::move(result_column));
323
3
                } else { // if(cond, null, not_nullable)
324
0
                    block.replace_by_position(
325
0
                            result,
326
0
                            ColumnNullable::create(materialize_column_if_const(arg_else.column),
327
0
                                                   arg_cond.column));
328
0
                }
329
3
            } else if (cond_const_col) {
330
0
                if (cond_const_col->get_value<UInt8>()) { // if(true, null, else)
331
0
                    block.get_by_position(result).column =
332
0
                            block.get_by_position(result).type->create_column()->clone_resized(
333
0
                                    input_rows_count);
334
0
                } else { // if(false, null, else)
335
0
                    block.get_by_position(result).column =
336
0
                            make_nullable_column_if_not(arg_else.column);
337
0
                }
338
0
            } else {
339
0
                return Status::InternalError(
340
0
                        "Illegal column {} of first argument of function {}. Must be ColumnUInt8 "
341
0
                        "or ColumnConstUInt8.",
342
0
                        arg_cond.column->get_name(), get_name());
343
0
            }
344
3
        } else { /// If else is NULL, we create Nullable column with null mask OR-ed with negated condition.
345
0
            if (cond_col) {
346
0
                size_t size = input_rows_count;
347
0
                auto& null_map_data = cond_col->get_data();
348
349
0
                auto negated_null_map = ColumnUInt8::create();
350
0
                auto& negated_null_map_data = negated_null_map->get_data();
351
0
                negated_null_map_data.resize(size);
352
353
0
                for (size_t i = 0; i < size; ++i) {
354
0
                    negated_null_map_data[i] = !null_map_data[i];
355
0
                }
356
357
0
                if (is_column_nullable(*arg_then.column)) { // if(cond, nullable, NULL)
358
0
                    auto arg_then_column = arg_then.column;
359
0
                    auto result_column = (*std::move(arg_then_column)).mutate();
360
0
                    assert_cast<ColumnNullable&>(*result_column)
361
0
                            .apply_negated_null_map(
362
0
                                    assert_cast<const ColumnUInt8&>(*arg_cond.column));
363
0
                    block.replace_by_position(result, std::move(result_column));
364
0
                } else { // if(cond, not_nullable, NULL)
365
0
                    block.replace_by_position(
366
0
                            result,
367
0
                            ColumnNullable::create(materialize_column_if_const(arg_then.column),
368
0
                                                   std::move(negated_null_map)));
369
0
                }
370
0
            } else if (cond_const_col) {
371
0
                if (cond_const_col->get_value<UInt8>()) { // if(true, then, NULL)
372
0
                    block.get_by_position(result).column =
373
0
                            make_nullable_column_if_not(arg_then.column);
374
0
                } else { // if(false, then, NULL)
375
0
                    block.get_by_position(result).column =
376
0
                            block.get_by_position(result).type->create_column()->clone_resized(
377
0
                                    input_rows_count);
378
0
                }
379
0
            } else {
380
0
                return Status::InternalError(
381
0
                        "Illegal column {} of first argument of function {}. Must be ColumnUInt8 "
382
0
                        "or ColumnConstUInt8.",
383
0
                        arg_cond.column->get_name(), get_name());
384
0
            }
385
0
        }
386
3
        handled = true;
387
3
        return Status::OK();
388
3
    }
389
390
    Status execute_for_nullable_then_else(FunctionContext* context, Block& block,
391
                                          const ColumnWithTypeAndName& arg_cond,
392
                                          const ColumnWithTypeAndName& arg_then,
393
                                          const ColumnWithTypeAndName& arg_else, size_t result,
394
15
                                          size_t input_rows_count, bool& handled) {
395
15
        auto then_type_is_nullable = arg_then.type->is_nullable();
396
15
        auto else_type_is_nullable = arg_else.type->is_nullable();
397
15
        if (!then_type_is_nullable && !else_type_is_nullable) {
398
10
            return Status::OK();
399
10
        }
400
401
5
        auto* then_is_nullable = check_and_get_column<ColumnNullable>(*arg_then.column);
402
5
        auto* else_is_nullable = check_and_get_column<ColumnNullable>(*arg_else.column);
403
5
        bool then_column_is_const_nullable = false;
404
5
        bool else_column_is_const_nullable = false;
405
5
        if (then_type_is_nullable && then_is_nullable == nullptr) {
406
            //this case is a const(nullable column)
407
0
            auto& const_column = assert_cast<const ColumnConst&>(*arg_then.column);
408
0
            then_is_nullable =
409
0
                    assert_cast<const ColumnNullable*>(const_column.get_data_column_ptr().get());
410
0
            then_column_is_const_nullable = true;
411
0
        }
412
413
5
        if (else_type_is_nullable && else_is_nullable == nullptr) {
414
            //this case is a const(nullable column)
415
0
            auto& const_column = assert_cast<const ColumnConst&>(*arg_else.column);
416
0
            else_is_nullable =
417
0
                    assert_cast<const ColumnNullable*>(const_column.get_data_column_ptr().get());
418
0
            else_column_is_const_nullable = true;
419
0
        }
420
421
        /** Calculate null mask of result and nested column separately.
422
          */
423
5
        ColumnPtr result_null_mask;
424
5
        {
425
            // get null map from column:
426
            // a. get_null_map_column_ptr() : it's a real nullable column, so could get it from nullable column
427
            // b. create a const_nullmap_column: it's a not nullable column or a const nullable column, contain a const value
428
5
            Block temporary_block;
429
5
            temporary_block.insert(arg_cond);
430
5
            auto then_nested_null_map =
431
5
                    (then_type_is_nullable && !then_column_is_const_nullable)
432
5
                            ? then_is_nullable->get_null_map_column_ptr()
433
5
                            : DataTypeUInt8().create_column_const_with_default_value(
434
0
                                      input_rows_count);
435
5
            temporary_block.insert({then_nested_null_map, std::make_shared<DataTypeUInt8>(),
436
5
                                    "then_column_null_map"});
437
438
5
            auto else_nested_null_map =
439
5
                    (else_type_is_nullable && !else_column_is_const_nullable)
440
5
                            ? else_is_nullable->get_null_map_column_ptr()
441
5
                            : DataTypeUInt8().create_column_const_with_default_value(
442
0
                                      input_rows_count);
443
5
            temporary_block.insert({else_nested_null_map, std::make_shared<DataTypeUInt8>(),
444
5
                                    "else_column_null_map"});
445
5
            temporary_block.insert(
446
5
                    {nullptr, std::make_shared<DataTypeUInt8>(), "result_column_null_map"});
447
448
5
            RETURN_IF_ERROR(
449
5
                    execute_impl(context, temporary_block, {0, 1, 2}, 3, temporary_block.rows()));
450
451
5
            result_null_mask = temporary_block.get_by_position(3).column;
452
5
        }
453
454
0
        ColumnPtr result_nested_column;
455
456
5
        {
457
5
            Block temporary_block(
458
5
                    {arg_cond,
459
5
                     {get_nested_column(arg_then.column), remove_nullable(arg_then.type), ""},
460
5
                     {get_nested_column(arg_else.column), remove_nullable(arg_else.type), ""},
461
5
                     {nullptr, remove_nullable(block.get_by_position(result).type), ""}});
462
463
5
            RETURN_IF_ERROR(
464
5
                    execute_impl(context, temporary_block, {0, 1, 2}, 3, temporary_block.rows()));
465
466
5
            result_nested_column = temporary_block.get_by_position(3).column;
467
5
        }
468
469
0
        auto column = ColumnNullable::create(materialize_column_if_const(result_nested_column),
470
5
                                             materialize_column_if_const(result_null_mask));
471
5
        block.replace_by_position(result, std::move(column));
472
5
        handled = true;
473
5
        return Status::OK();
474
5
    }
475
476
    Status execute_for_null_condition(FunctionContext* context, Block& block,
477
                                      const ColumnNumbers& arguments,
478
                                      const ColumnWithTypeAndName& arg_cond,
479
                                      const ColumnWithTypeAndName& arg_then,
480
                                      const ColumnWithTypeAndName& arg_else, size_t result,
481
21
                                      bool& handled) {
482
21
        bool cond_is_null = arg_cond.column->only_null();
483
484
21
        if (cond_is_null) {
485
0
            block.replace_by_position(result,
486
0
                                      arg_else.column->clone_resized(arg_cond.column->size()));
487
0
            handled = true;
488
0
            return Status::OK();
489
0
        }
490
491
21
        if (auto* nullable = check_and_get_column<ColumnNullable>(*arg_cond.column)) {
492
3
            DCHECK(remove_nullable(arg_cond.type)->get_type_id() == TypeIndex::UInt8);
493
494
            // update nested column by null map
495
3
            auto* __restrict null_map = nullable->get_null_map_data().data();
496
3
            auto* __restrict nested_bool_data =
497
3
                    ((ColumnVector<UInt8>&)(nullable->get_nested_column())).get_data().data();
498
3
            auto rows = nullable->size();
499
12
            for (size_t i = 0; i < rows; i++) {
500
9
                nested_bool_data[i] = null_map[i] ? 0 : nested_bool_data[i];
501
9
            }
502
3
            auto column_size = block.columns();
503
3
            block.insert({nullable->get_nested_column_ptr(), remove_nullable(arg_cond.type),
504
3
                          arg_cond.name});
505
506
3
            handled = true;
507
3
            return execute_impl(context, block, {column_size, arguments[1], arguments[2]}, result,
508
3
                                rows);
509
3
        }
510
18
        return Status::OK();
511
21
    }
512
513
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
514
21
                        size_t result, size_t input_rows_count) override {
515
21
        const ColumnWithTypeAndName& arg_then = block.get_by_position(arguments[1]);
516
21
        const ColumnWithTypeAndName& arg_else = block.get_by_position(arguments[2]);
517
518
        /// A case for identical then and else (pointers are the same).
519
21
        if (arg_then.column.get() == arg_else.column.get()) {
520
            /// Just point result to them.
521
0
            block.replace_by_position(result, arg_then.column);
522
0
            return Status::OK();
523
0
        }
524
525
21
        ColumnWithTypeAndName& cond_column = block.get_by_position(arguments[0]);
526
21
        cond_column.column = materialize_column_if_const(cond_column.column);
527
21
        const ColumnWithTypeAndName& arg_cond = block.get_by_position(arguments[0]);
528
529
21
        Status ret = Status::OK();
530
21
        bool handled = false;
531
21
        RETURN_IF_ERROR(execute_for_null_condition(context, block, arguments, arg_cond, arg_then,
532
21
                                                   arg_else, result, handled));
533
21
        if (!handled) {
534
18
            RETURN_IF_ERROR(execute_for_null_then_else(context, block, arg_cond, arg_then, arg_else,
535
18
                                                       result, input_rows_count, handled));
536
18
        }
537
21
        if (!handled) {
538
15
            RETURN_IF_ERROR(execute_for_nullable_then_else(context, block, arg_cond, arg_then,
539
15
                                                           arg_else, result, input_rows_count,
540
15
                                                           handled));
541
15
        }
542
21
        if (handled) {
543
11
            return Status::OK();
544
11
        }
545
546
10
        const ColumnUInt8* cond_col = typeid_cast<const ColumnUInt8*>(arg_cond.column.get());
547
10
        const ColumnConst* cond_const_col =
548
10
                check_and_get_column_const<ColumnVector<UInt8>>(arg_cond.column.get());
549
550
10
        if (cond_const_col) {
551
0
            block.get_by_position(result).column =
552
0
                    cond_const_col->get_value<UInt8>() ? arg_then.column : arg_else.column;
553
0
            return Status::OK();
554
0
        }
555
556
10
        if (!cond_col) {
557
0
            return Status::InvalidArgument(
558
0
                    "Illegal column {} of first argument of function {},Must be ColumnUInt8 or "
559
0
                    "ColumnConstUInt8.",
560
0
                    arg_cond.column->get_name(), get_name());
561
0
        }
562
563
10
        WhichDataType which_type(arg_then.type);
564
10
        if (which_type.is_int() || which_type.is_float()) {
565
3
            Status status;
566
3
            execute_basic_type(block, cond_col, arg_then, arg_else, result, status);
567
3
            return status;
568
7
        } else {
569
7
            return execute_generic(block, cond_col, arg_then, arg_else, result, input_rows_count);
570
7
        }
571
10
    }
572
};
573
574
1
void register_function_if(SimpleFunctionFactory& factory) {
575
1
    factory.register_function<FunctionIf>();
576
1
}
577
578
} // namespace doris::vectorized