Coverage Report

Created: 2026-05-25 21:25

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.2k
inline bool CastToBool::from_string(const StringRef& from, UInt8& to, CastParameters&) {
116
11.2k
    StringParser::ParseResult result;
117
11.2k
    to = StringParser::string_to_bool(from.data, from.size, &result);
118
11.2k
    return result == StringParser::PARSE_SUCCESS;
119
11.2k
}
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 = assert_cast<const 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 nested_to_type = remove_nullable(to_type);
131
12
        auto serde = nested_to_type->get_serde();
132
133
12
        if constexpr (Mode == CastModeType::NonStrictMode) {
134
1
            auto nullable_col_to = create_empty_nullable_column(nested_to_type);
135
            // may write nulls to nullable_col_to
136
1
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
137
1
            block.get_by_position(result).column = std::move(nullable_col_to);
138
11
        } else if constexpr (Mode == CastModeType::StrictMode) {
139
11
            MutableColumnPtr column_to = nested_to_type->create_column();
140
            // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows
141
11
            RETURN_IF_ERROR(
142
11
                    serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map));
143
1
            block.get_by_position(result).column = std::move(column_to);
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
0
        return Status::OK();
149
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 = assert_cast<const 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 nested_to_type = remove_nullable(to_type);
131
11
        auto serde = nested_to_type->get_serde();
132
133
        if constexpr (Mode == CastModeType::NonStrictMode) {
134
            auto nullable_col_to = create_empty_nullable_column(nested_to_type);
135
            // may write nulls to nullable_col_to
136
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
137
            block.get_by_position(result).column = std::move(nullable_col_to);
138
11
        } else if constexpr (Mode == CastModeType::StrictMode) {
139
11
            MutableColumnPtr column_to = nested_to_type->create_column();
140
            // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows
141
11
            RETURN_IF_ERROR(
142
11
                    serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map));
143
1
            block.get_by_position(result).column = std::move(column_to);
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
0
        return Status::OK();
149
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 = assert_cast<const 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 nested_to_type = remove_nullable(to_type);
131
1
        auto serde = nested_to_type->get_serde();
132
133
1
        if constexpr (Mode == CastModeType::NonStrictMode) {
134
1
            auto nullable_col_to = create_empty_nullable_column(nested_to_type);
135
            // may write nulls to nullable_col_to
136
1
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
137
1
            block.get_by_position(result).column = std::move(nullable_col_to);
138
        } else if constexpr (Mode == CastModeType::StrictMode) {
139
            MutableColumnPtr column_to = nested_to_type->create_column();
140
            // WON'T write nulls to the result column, just raise errors. null_map is only used to skip invalid rows
141
            RETURN_IF_ERROR(
142
                    serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map));
143
            block.get_by_position(result).column = std::move(column_to);
144
        } else {
145
            return Status::InternalError("Unsupported cast mode");
146
        }
147
148
0
        return Status::OK();
149
1
    }
150
};
151
template <CastModeType AllMode, typename NumberType>
152
    requires(IsDataTypeNumber<NumberType>)
153
class CastToImpl<AllMode, NumberType, DataTypeBool> : public CastToBase {
154
public:
155
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
156
                        uint32_t result, size_t input_rows_count,
157
10
                        const NullMap::value_type* null_map = nullptr) const override {
158
10
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
10
                block.get_by_position(arguments[0]).column.get());
160
10
        DataTypeBool::ColumnType::MutablePtr col_to =
161
10
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
10
        CastParameters params;
164
10
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
56
        for (size_t i = 0; i < input_rows_count; ++i) {
166
46
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
46
        }
168
169
10
        block.get_by_position(result).column = std::move(col_to);
170
10
        return Status::OK();
171
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
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
4
        for (size_t i = 0; i < input_rows_count; ++i) {
166
3
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
3
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
7
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
7
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
7
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
1
                        const NullMap::value_type* null_map = nullptr) const override {
158
1
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
1
                block.get_by_position(arguments[0]).column.get());
160
1
        DataTypeBool::ColumnType::MutablePtr col_to =
161
1
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
1
        CastParameters params;
164
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
7
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
7
        }
168
169
1
        block.get_by_position(result).column = std::move(col_to);
170
1
        return Status::OK();
171
1
    }
172
};
173
174
template <CastModeType AllMode, typename DecimalType>
175
    requires(IsDataTypeDecimal<DecimalType>)
176
class CastToImpl<AllMode, DecimalType, DataTypeBool> : public CastToBase {
177
public:
178
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
179
                        uint32_t result, size_t input_rows_count,
180
10
                        const NullMap::value_type* null_map = nullptr) const override {
181
10
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
10
                block.get_by_position(arguments[0]).column.get());
183
10
        const auto type_from = block.get_by_position(arguments[0]).type;
184
10
        DataTypeBool::ColumnType::MutablePtr col_to =
185
10
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
10
        CastParameters params;
188
10
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
10
        auto precision = type_from->get_precision();
191
10
        auto scale = type_from->get_scale();
192
80
        for (size_t i = 0; i < input_rows_count; ++i) {
193
70
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
70
                                     scale, params);
195
70
        }
196
197
10
        block.get_by_position(result).column = std::move(col_to);
198
10
        return Status::OK();
199
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
1
                        const NullMap::value_type* null_map = nullptr) const override {
181
1
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
1
                block.get_by_position(arguments[0]).column.get());
183
1
        const auto type_from = block.get_by_position(arguments[0]).type;
184
1
        DataTypeBool::ColumnType::MutablePtr col_to =
185
1
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
1
        CastParameters params;
188
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
1
        auto precision = type_from->get_precision();
191
1
        auto scale = type_from->get_scale();
192
8
        for (size_t i = 0; i < input_rows_count; ++i) {
193
7
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
7
                                     scale, params);
195
7
        }
196
197
1
        block.get_by_position(result).column = std::move(col_to);
198
1
        return Status::OK();
199
1
    }
200
};
201
202
} // namespace doris