Coverage Report

Created: 2026-04-20 20:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/cast_to_boolean.h
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
#pragma once
19
20
#include "core/types.h"
21
#include "exprs/function/cast/cast_base.h"
22
#include "util/string_parser.hpp"
23
24
namespace doris {
25
26
struct CastToBool {
27
    template <class SRC>
28
    static inline bool from_number(const SRC& from, UInt8& to, CastParameters& params);
29
30
    template <class SRC>
31
    static inline bool from_decimal(const SRC& from, UInt8& to, UInt32 precision, UInt32 scale,
32
                                    CastParameters& params);
33
34
    static inline bool from_string(const StringRef& from, UInt8& to, CastParameters& params);
35
};
36
37
template <>
38
4
inline bool CastToBool::from_number(const UInt8& from, UInt8& to, CastParameters&) {
39
4
    to = from;
40
4
    return true;
41
4
}
42
43
template <>
44
2
inline bool CastToBool::from_number(const Int8& from, UInt8& to, CastParameters&) {
45
2
    to = (from != 0);
46
2
    return true;
47
2
}
48
template <>
49
2
inline bool CastToBool::from_number(const Int16& from, UInt8& to, CastParameters&) {
50
2
    to = (from != 0);
51
2
    return true;
52
2
}
53
template <>
54
8
inline bool CastToBool::from_number(const Int32& from, UInt8& to, CastParameters&) {
55
8
    to = (from != 0);
56
8
    return true;
57
8
}
58
template <>
59
8
inline bool CastToBool::from_number(const Int64& from, UInt8& to, CastParameters&) {
60
8
    to = (from != 0);
61
8
    return true;
62
8
}
63
template <>
64
7
inline bool CastToBool::from_number(const Int128& from, UInt8& to, CastParameters&) {
65
7
    to = (from != 0);
66
7
    return true;
67
7
}
68
69
template <>
70
15
inline bool CastToBool::from_number(const Float32& from, UInt8& to, CastParameters&) {
71
15
    to = (from != 0);
72
15
    return true;
73
15
}
74
template <>
75
16
inline bool CastToBool::from_number(const Float64& from, UInt8& to, CastParameters&) {
76
16
    to = (from != 0);
77
16
    return true;
78
16
}
79
80
template <>
81
inline bool CastToBool::from_decimal(const Decimal32& from, UInt8& to, UInt32, UInt32,
82
15
                                     CastParameters&) {
83
15
    to = (from.value != 0);
84
15
    return true;
85
15
}
86
87
template <>
88
inline bool CastToBool::from_decimal(const Decimal64& from, UInt8& to, UInt32, UInt32,
89
15
                                     CastParameters&) {
90
15
    to = (from.value != 0);
91
15
    return true;
92
15
}
93
94
template <>
95
inline bool CastToBool::from_decimal(const DecimalV2Value& from, UInt8& to, UInt32, UInt32,
96
14
                                     CastParameters&) {
97
14
    to = (from.value() != 0);
98
14
    return true;
99
14
}
100
101
template <>
102
inline bool CastToBool::from_decimal(const Decimal128V3& from, UInt8& to, UInt32, UInt32,
103
15
                                     CastParameters&) {
104
15
    to = (from.value != 0);
105
15
    return true;
106
15
}
107
108
template <>
109
inline bool CastToBool::from_decimal(const Decimal256& from, UInt8& to, UInt32, UInt32,
110
15
                                     CastParameters&) {
111
15
    to = (from.value != 0);
112
15
    return true;
113
15
}
114
115
11.0k
inline bool CastToBool::from_string(const StringRef& from, UInt8& to, CastParameters&) {
116
11.0k
    StringParser::ParseResult result;
117
11.0k
    to = StringParser::string_to_bool(from.data, from.size, &result);
118
11.0k
    return result == StringParser::PARSE_SUCCESS;
119
11.0k
}
120
121
template <CastModeType Mode>
122
class CastToImpl<Mode, DataTypeString, DataTypeBool> : public CastToBase {
123
public:
124
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
125
                        uint32_t result, size_t input_rows_count,
126
12
                        const NullMap::value_type* null_map = nullptr) const override {
127
12
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
128
12
                block.get_by_position(arguments[0]).column.get());
129
12
        auto to_type = block.get_by_position(result).type;
130
12
        auto serde = remove_nullable(to_type)->get_serde();
131
132
        // by default framework, to_type is already unwrapped nullable
133
12
        MutableColumnPtr column_to = to_type->create_column();
134
12
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
135
12
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
136
137
12
        if constexpr (Mode == CastModeType::NonStrictMode) {
138
            // may write nulls to nullable_col_to
139
1
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
140
11
        } else if constexpr (Mode == CastModeType::StrictMode) {
141
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
142
11
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
143
11
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
2
        block.get_by_position(result).column = std::move(nullable_col_to);
149
12
        return Status::OK();
150
12
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
126
11
                        const NullMap::value_type* null_map = nullptr) const override {
127
11
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
128
11
                block.get_by_position(arguments[0]).column.get());
129
11
        auto to_type = block.get_by_position(result).type;
130
11
        auto serde = remove_nullable(to_type)->get_serde();
131
132
        // by default framework, to_type is already unwrapped nullable
133
11
        MutableColumnPtr column_to = to_type->create_column();
134
11
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
135
11
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
136
137
        if constexpr (Mode == CastModeType::NonStrictMode) {
138
            // may write nulls to nullable_col_to
139
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
140
11
        } else if constexpr (Mode == CastModeType::StrictMode) {
141
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
142
11
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
143
11
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
1
        block.get_by_position(result).column = std::move(nullable_col_to);
149
11
        return Status::OK();
150
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
126
1
                        const NullMap::value_type* null_map = nullptr) const override {
127
1
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
128
1
                block.get_by_position(arguments[0]).column.get());
129
1
        auto to_type = block.get_by_position(result).type;
130
1
        auto serde = remove_nullable(to_type)->get_serde();
131
132
        // by default framework, to_type is already unwrapped nullable
133
1
        MutableColumnPtr column_to = to_type->create_column();
134
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
135
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
136
137
1
        if constexpr (Mode == CastModeType::NonStrictMode) {
138
            // may write nulls to nullable_col_to
139
1
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
140
        } else if constexpr (Mode == CastModeType::StrictMode) {
141
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
142
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
143
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
1
        block.get_by_position(result).column = std::move(nullable_col_to);
149
1
        return Status::OK();
150
1
    }
151
};
152
template <CastModeType AllMode, typename NumberType>
153
    requires(IsDataTypeNumber<NumberType>)
154
class CastToImpl<AllMode, NumberType, DataTypeBool> : public CastToBase {
155
public:
156
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
157
                        uint32_t result, size_t input_rows_count,
158
10
                        const NullMap::value_type* null_map = nullptr) const override {
159
10
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
10
                block.get_by_position(arguments[0]).column.get());
161
10
        DataTypeBool::ColumnType::MutablePtr col_to =
162
10
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
10
        CastParameters params;
165
10
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
56
        for (size_t i = 0; i < input_rows_count; ++i) {
167
46
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
46
        }
169
170
10
        block.get_by_position(result).column = std::move(col_to);
171
10
        return Status::OK();
172
10
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
4
        for (size_t i = 0; i < input_rows_count; ++i) {
167
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
3
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
8
        for (size_t i = 0; i < input_rows_count; ++i) {
167
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
7
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
8
        for (size_t i = 0; i < input_rows_count; ++i) {
167
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
7
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
8
        for (size_t i = 0; i < input_rows_count; ++i) {
167
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
7
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
158
1
                        const NullMap::value_type* null_map = nullptr) const override {
159
1
        const auto* col_from = check_and_get_column<typename NumberType::ColumnType>(
160
1
                block.get_by_position(arguments[0]).column.get());
161
1
        DataTypeBool::ColumnType::MutablePtr col_to =
162
1
                DataTypeBool::ColumnType::create(input_rows_count);
163
164
1
        CastParameters params;
165
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
166
8
        for (size_t i = 0; i < input_rows_count; ++i) {
167
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
168
7
        }
169
170
1
        block.get_by_position(result).column = std::move(col_to);
171
1
        return Status::OK();
172
1
    }
173
};
174
175
template <CastModeType AllMode, typename DecimalType>
176
    requires(IsDataTypeDecimal<DecimalType>)
177
class CastToImpl<AllMode, DecimalType, DataTypeBool> : public CastToBase {
178
public:
179
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
180
                        uint32_t result, size_t input_rows_count,
181
10
                        const NullMap::value_type* null_map = nullptr) const override {
182
10
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
10
                block.get_by_position(arguments[0]).column.get());
184
10
        const auto type_from = block.get_by_position(arguments[0]).type;
185
10
        DataTypeBool::ColumnType::MutablePtr col_to =
186
10
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
10
        CastParameters params;
189
10
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
10
        auto precision = type_from->get_precision();
192
10
        auto scale = type_from->get_scale();
193
80
        for (size_t i = 0; i < input_rows_count; ++i) {
194
70
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
70
                                     scale, params);
196
70
        }
197
198
10
        block.get_by_position(result).column = std::move(col_to);
199
10
        return Status::OK();
200
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
181
1
                        const NullMap::value_type* null_map = nullptr) const override {
182
1
        const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>(
183
1
                block.get_by_position(arguments[0]).column.get());
184
1
        const auto type_from = block.get_by_position(arguments[0]).type;
185
1
        DataTypeBool::ColumnType::MutablePtr col_to =
186
1
                DataTypeBool::ColumnType::create(input_rows_count);
187
188
1
        CastParameters params;
189
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
190
191
1
        auto precision = type_from->get_precision();
192
1
        auto scale = type_from->get_scale();
193
8
        for (size_t i = 0; i < input_rows_count; ++i) {
194
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
195
7
                                     scale, params);
196
7
        }
197
198
1
        block.get_by_position(result).column = std::move(col_to);
199
1
        return Status::OK();
200
1
    }
201
};
202
203
} // namespace doris