Coverage Report

Created: 2026-07-25 15:41

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
8
inline bool CastToBool::from_number(const UInt8& from, UInt8& to, CastParameters&) {
39
8
    to = from;
40
8
    return true;
41
8
}
42
43
template <>
44
4
inline bool CastToBool::from_number(const Int8& from, UInt8& to, CastParameters&) {
45
4
    to = (from != 0);
46
4
    return true;
47
4
}
48
template <>
49
4
inline bool CastToBool::from_number(const Int16& from, UInt8& to, CastParameters&) {
50
4
    to = (from != 0);
51
4
    return true;
52
4
}
53
template <>
54
16
inline bool CastToBool::from_number(const Int32& from, UInt8& to, CastParameters&) {
55
16
    to = (from != 0);
56
16
    return true;
57
16
}
58
template <>
59
16
inline bool CastToBool::from_number(const Int64& from, UInt8& to, CastParameters&) {
60
16
    to = (from != 0);
61
16
    return true;
62
16
}
63
template <>
64
14
inline bool CastToBool::from_number(const Int128& from, UInt8& to, CastParameters&) {
65
14
    to = (from != 0);
66
14
    return true;
67
14
}
68
69
template <>
70
30
inline bool CastToBool::from_number(const Float32& from, UInt8& to, CastParameters&) {
71
30
    to = (from != 0);
72
30
    return true;
73
30
}
74
template <>
75
32
inline bool CastToBool::from_number(const Float64& from, UInt8& to, CastParameters&) {
76
32
    to = (from != 0);
77
32
    return true;
78
32
}
79
80
template <>
81
inline bool CastToBool::from_decimal(const Decimal32& from, UInt8& to, UInt32, UInt32,
82
30
                                     CastParameters&) {
83
30
    to = (from.value != 0);
84
30
    return true;
85
30
}
86
87
template <>
88
inline bool CastToBool::from_decimal(const Decimal64& from, UInt8& to, UInt32, UInt32,
89
30
                                     CastParameters&) {
90
30
    to = (from.value != 0);
91
30
    return true;
92
30
}
93
94
template <>
95
inline bool CastToBool::from_decimal(const DecimalV2Value& from, UInt8& to, UInt32, UInt32,
96
28
                                     CastParameters&) {
97
28
    to = (from.value() != 0);
98
28
    return true;
99
28
}
100
101
template <>
102
inline bool CastToBool::from_decimal(const Decimal128V3& from, UInt8& to, UInt32, UInt32,
103
30
                                     CastParameters&) {
104
30
    to = (from.value != 0);
105
30
    return true;
106
30
}
107
108
template <>
109
inline bool CastToBool::from_decimal(const Decimal256& from, UInt8& to, UInt32, UInt32,
110
30
                                     CastParameters&) {
111
30
    to = (from.value != 0);
112
30
    return true;
113
30
}
114
115
22.1k
inline bool CastToBool::from_string(const StringRef& from, UInt8& to, CastParameters&) {
116
22.1k
    StringParser::ParseResult result;
117
22.1k
    to = StringParser::string_to_bool(from.data, from.size, &result);
118
22.1k
    return result == StringParser::PARSE_SUCCESS;
119
22.1k
}
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
24
                        const NullMap::value_type* null_map = nullptr) const override {
127
24
        const auto* col_from = assert_cast<const DataTypeString::ColumnType*>(
128
24
                block.get_by_position(arguments[0]).column.get());
129
24
        auto to_type = block.get_by_position(result).type;
130
24
        auto nested_to_type = remove_nullable(to_type);
131
24
        auto serde = nested_to_type->get_serde();
132
133
24
        if constexpr (Mode == CastModeType::NonStrictMode) {
134
2
            auto nullable_col_to = create_empty_nullable_column(nested_to_type);
135
            // may write nulls to nullable_col_to
136
2
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
137
2
            block.get_by_position(result).column = std::move(nullable_col_to);
138
22
        } else if constexpr (Mode == CastModeType::StrictMode) {
139
22
            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
22
            RETURN_IF_ERROR(
142
22
                    serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map));
143
2
            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
24
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
126
22
                        const NullMap::value_type* null_map = nullptr) const override {
127
22
        const auto* col_from = assert_cast<const DataTypeString::ColumnType*>(
128
22
                block.get_by_position(arguments[0]).column.get());
129
22
        auto to_type = block.get_by_position(result).type;
130
22
        auto nested_to_type = remove_nullable(to_type);
131
22
        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
22
        } else if constexpr (Mode == CastModeType::StrictMode) {
139
22
            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
22
            RETURN_IF_ERROR(
142
22
                    serde->from_string_strict_mode_batch(*col_from, *column_to, {}, null_map));
143
2
            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
22
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
126
2
                        const NullMap::value_type* null_map = nullptr) const override {
127
2
        const auto* col_from = assert_cast<const DataTypeString::ColumnType*>(
128
2
                block.get_by_position(arguments[0]).column.get());
129
2
        auto to_type = block.get_by_position(result).type;
130
2
        auto nested_to_type = remove_nullable(to_type);
131
2
        auto serde = nested_to_type->get_serde();
132
133
2
        if constexpr (Mode == CastModeType::NonStrictMode) {
134
2
            auto nullable_col_to = create_empty_nullable_column(nested_to_type);
135
            // may write nulls to nullable_col_to
136
2
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
137
2
            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
2
    }
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
20
                        const NullMap::value_type* null_map = nullptr) const override {
158
20
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
20
                block.get_by_position(arguments[0]).column.get());
160
20
        DataTypeBool::ColumnType::MutablePtr col_to =
161
20
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
20
        CastParameters params;
164
20
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
112
        for (size_t i = 0; i < input_rows_count; ++i) {
166
92
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
92
        }
168
169
20
        block.get_by_position(result).column = std::move(col_to);
170
20
        return Status::OK();
171
20
    }
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
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
8
        for (size_t i = 0; i < input_rows_count; ++i) {
166
6
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
6
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
16
        for (size_t i = 0; i < input_rows_count; ++i) {
166
14
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
14
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
16
        for (size_t i = 0; i < input_rows_count; ++i) {
166
14
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
14
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
16
        for (size_t i = 0; i < input_rows_count; ++i) {
166
14
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
14
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
157
2
                        const NullMap::value_type* null_map = nullptr) const override {
158
2
        const auto* col_from = assert_cast<const typename NumberType::ColumnType*>(
159
2
                block.get_by_position(arguments[0]).column.get());
160
2
        DataTypeBool::ColumnType::MutablePtr col_to =
161
2
                DataTypeBool::ColumnType::create(input_rows_count);
162
163
2
        CastParameters params;
164
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
165
16
        for (size_t i = 0; i < input_rows_count; ++i) {
166
14
            CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params);
167
14
        }
168
169
2
        block.get_by_position(result).column = std::move(col_to);
170
2
        return Status::OK();
171
2
    }
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
20
                        const NullMap::value_type* null_map = nullptr) const override {
181
20
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
20
                block.get_by_position(arguments[0]).column.get());
183
20
        const auto type_from = block.get_by_position(arguments[0]).type;
184
20
        DataTypeBool::ColumnType::MutablePtr col_to =
185
20
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
20
        CastParameters params;
188
20
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
20
        auto precision = type_from->get_precision();
191
20
        auto scale = type_from->get_scale();
192
160
        for (size_t i = 0; i < input_rows_count; ++i) {
193
140
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
140
                                     scale, params);
195
140
        }
196
197
20
        block.get_by_position(result).column = std::move(col_to);
198
20
        return Status::OK();
199
20
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
180
2
                        const NullMap::value_type* null_map = nullptr) const override {
181
2
        const auto* col_from = assert_cast<const typename DecimalType::ColumnType*>(
182
2
                block.get_by_position(arguments[0]).column.get());
183
2
        const auto type_from = block.get_by_position(arguments[0]).type;
184
2
        DataTypeBool::ColumnType::MutablePtr col_to =
185
2
                DataTypeBool::ColumnType::create(input_rows_count);
186
187
2
        CastParameters params;
188
2
        params.is_strict = (AllMode == CastModeType::StrictMode);
189
190
2
        auto precision = type_from->get_precision();
191
2
        auto scale = type_from->get_scale();
192
16
        for (size_t i = 0; i < input_rows_count; ++i) {
193
14
            CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision,
194
14
                                     scale, params);
195
14
        }
196
197
2
        block.get_by_position(result).column = std::move(col_to);
198
2
        return Status::OK();
199
2
    }
200
};
201
202
} // namespace doris