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/io_helper.h" |
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 | 122 | inline bool CastToBool::from_string(const StringRef& from, UInt8& to, CastParameters&) { |
116 | 122 | return try_read_bool_text(to, from); |
117 | 122 | } |
118 | | |
119 | | template <CastModeType Mode> |
120 | | class CastToImpl<Mode, DataTypeString, DataTypeBool> : public CastToBase { |
121 | | public: |
122 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
123 | | uint32_t result, size_t input_rows_count, |
124 | 12 | const NullMap::value_type* null_map = nullptr) const override { |
125 | 12 | const auto* col_from = check_and_get_column<DataTypeString::ColumnType>( |
126 | 12 | block.get_by_position(arguments[0]).column.get()); |
127 | 12 | auto to_type = block.get_by_position(result).type; |
128 | 12 | auto serde = remove_nullable(to_type)->get_serde(); |
129 | | |
130 | | // by default framework, to_type is already unwrapped nullable |
131 | 12 | MutableColumnPtr column_to = to_type->create_column(); |
132 | 12 | ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create( |
133 | 12 | std::move(column_to), ColumnUInt8::create(input_rows_count, 0)); |
134 | | |
135 | 12 | if constexpr (Mode == CastModeType::NonStrictMode) { |
136 | | // may write nulls to nullable_col_to |
137 | 1 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); |
138 | 11 | } else if constexpr (Mode == CastModeType::StrictMode) { |
139 | | // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows |
140 | 11 | RETURN_IF_ERROR(serde->from_string_strict_mode_batch( |
141 | 11 | *col_from, nullable_col_to->get_nested_column(), {}, null_map)); |
142 | | } else { |
143 | | return Status::InternalError("Unsupported cast mode"); |
144 | | } |
145 | | |
146 | 2 | block.get_by_position(result).column = std::move(nullable_col_to); |
147 | 12 | return Status::OK(); |
148 | 12 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 124 | 11 | const NullMap::value_type* null_map = nullptr) const override { | 125 | 11 | const auto* col_from = check_and_get_column<DataTypeString::ColumnType>( | 126 | 11 | block.get_by_position(arguments[0]).column.get()); | 127 | 11 | auto to_type = block.get_by_position(result).type; | 128 | 11 | auto serde = remove_nullable(to_type)->get_serde(); | 129 | | | 130 | | // by default framework, to_type is already unwrapped nullable | 131 | 11 | MutableColumnPtr column_to = to_type->create_column(); | 132 | 11 | ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create( | 133 | 11 | std::move(column_to), ColumnUInt8::create(input_rows_count, 0)); | 134 | | | 135 | | if constexpr (Mode == CastModeType::NonStrictMode) { | 136 | | // may write nulls to nullable_col_to | 137 | | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 138 | 11 | } else if constexpr (Mode == CastModeType::StrictMode) { | 139 | | // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows | 140 | 11 | RETURN_IF_ERROR(serde->from_string_strict_mode_batch( | 141 | 11 | *col_from, nullable_col_to->get_nested_column(), {}, null_map)); | 142 | | } else { | 143 | | return Status::InternalError("Unsupported cast mode"); | 144 | | } | 145 | | | 146 | 1 | block.get_by_position(result).column = std::move(nullable_col_to); | 147 | 11 | return Status::OK(); | 148 | 11 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 124 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 125 | 1 | const auto* col_from = check_and_get_column<DataTypeString::ColumnType>( | 126 | 1 | block.get_by_position(arguments[0]).column.get()); | 127 | 1 | auto to_type = block.get_by_position(result).type; | 128 | 1 | auto serde = remove_nullable(to_type)->get_serde(); | 129 | | | 130 | | // by default framework, to_type is already unwrapped nullable | 131 | 1 | MutableColumnPtr column_to = to_type->create_column(); | 132 | 1 | ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create( | 133 | 1 | std::move(column_to), ColumnUInt8::create(input_rows_count, 0)); | 134 | | | 135 | 1 | if constexpr (Mode == CastModeType::NonStrictMode) { | 136 | | // may write nulls to nullable_col_to | 137 | 1 | RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {})); | 138 | | } else if constexpr (Mode == CastModeType::StrictMode) { | 139 | | // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows | 140 | | RETURN_IF_ERROR(serde->from_string_strict_mode_batch( | 141 | | *col_from, nullable_col_to->get_nested_column(), {}, null_map)); | 142 | | } else { | 143 | | return Status::InternalError("Unsupported cast mode"); | 144 | | } | 145 | | | 146 | 1 | block.get_by_position(result).column = std::move(nullable_col_to); | 147 | 1 | return Status::OK(); | 148 | 1 | } |
|
149 | | }; |
150 | | template <CastModeType AllMode, typename NumberType> |
151 | | requires(IsDataTypeNumber<NumberType>) |
152 | | class CastToImpl<AllMode, NumberType, DataTypeBool> : public CastToBase { |
153 | | public: |
154 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
155 | | uint32_t result, size_t input_rows_count, |
156 | 10 | const NullMap::value_type* null_map = nullptr) const override { |
157 | 10 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( |
158 | 10 | block.get_by_position(arguments[0]).column.get()); |
159 | 10 | DataTypeBool::ColumnType::MutablePtr col_to = |
160 | 10 | DataTypeBool::ColumnType::create(input_rows_count); |
161 | | |
162 | 10 | CastParameters params; |
163 | 10 | params.is_strict = (AllMode == CastModeType::StrictMode); |
164 | 56 | for (size_t i = 0; i < input_rows_count; ++i) { |
165 | 46 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); |
166 | 46 | } |
167 | | |
168 | 10 | block.get_by_position(result).column = std::move(col_to); |
169 | 10 | return Status::OK(); |
170 | 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 | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 4 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 3 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 3 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 7 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 7 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 7 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 7 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 7 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 7 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 156 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 157 | 1 | const auto* col_from = check_and_get_column<typename NumberType::ColumnType>( | 158 | 1 | block.get_by_position(arguments[0]).column.get()); | 159 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 160 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 161 | | | 162 | 1 | CastParameters params; | 163 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 164 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 165 | 7 | CastToBool::from_number(col_from->get_element(i), col_to->get_element(i), params); | 166 | 7 | } | 167 | | | 168 | 1 | block.get_by_position(result).column = std::move(col_to); | 169 | 1 | return Status::OK(); | 170 | 1 | } |
|
171 | | }; |
172 | | |
173 | | template <CastModeType AllMode, typename DecimalType> |
174 | | requires(IsDataTypeDecimal<DecimalType>) |
175 | | class CastToImpl<AllMode, DecimalType, DataTypeBool> : public CastToBase { |
176 | | public: |
177 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
178 | | uint32_t result, size_t input_rows_count, |
179 | 10 | const NullMap::value_type* null_map = nullptr) const override { |
180 | 10 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( |
181 | 10 | block.get_by_position(arguments[0]).column.get()); |
182 | 10 | const auto type_from = block.get_by_position(arguments[0]).type; |
183 | 10 | DataTypeBool::ColumnType::MutablePtr col_to = |
184 | 10 | DataTypeBool::ColumnType::create(input_rows_count); |
185 | | |
186 | 10 | CastParameters params; |
187 | 10 | params.is_strict = (AllMode == CastModeType::StrictMode); |
188 | | |
189 | 10 | auto precision = type_from->get_precision(); |
190 | 10 | auto scale = type_from->get_scale(); |
191 | 80 | for (size_t i = 0; i < input_rows_count; ++i) { |
192 | 70 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, |
193 | 70 | scale, params); |
194 | 70 | } |
195 | | |
196 | 10 | block.get_by_position(result).column = std::move(col_to); |
197 | 10 | return Status::OK(); |
198 | 10 | } _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_2EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 179 | 1 | const NullMap::value_type* null_map = nullptr) const override { | 180 | 1 | const auto* col_from = check_and_get_column<typename DecimalType::ColumnType>( | 181 | 1 | block.get_by_position(arguments[0]).column.get()); | 182 | 1 | const auto type_from = block.get_by_position(arguments[0]).type; | 183 | 1 | DataTypeBool::ColumnType::MutablePtr col_to = | 184 | 1 | DataTypeBool::ColumnType::create(input_rows_count); | 185 | | | 186 | 1 | CastParameters params; | 187 | 1 | params.is_strict = (AllMode == CastModeType::StrictMode); | 188 | | | 189 | 1 | auto precision = type_from->get_precision(); | 190 | 1 | auto scale = type_from->get_scale(); | 191 | 8 | for (size_t i = 0; i < input_rows_count; ++i) { | 192 | 7 | CastToBool::from_decimal(col_from->get_element(i), col_to->get_element(i), precision, | 193 | 7 | scale, params); | 194 | 7 | } | 195 | | | 196 | 1 | block.get_by_position(result).column = std::move(col_to); | 197 | 1 | return Status::OK(); | 198 | 1 | } |
|
199 | | }; |
200 | | |
201 | | namespace CastWrapper { |
202 | 32 | inline WrapperType create_boolean_wrapper(FunctionContext* context, const DataTypePtr& from_type) { |
203 | 32 | std::shared_ptr<CastToBase> cast_to_bool; |
204 | | |
205 | 32 | auto make_bool_wrapper = [&](const auto& types) -> bool { |
206 | 32 | using Types = std::decay_t<decltype(types)>; |
207 | 32 | using FromDataType = typename Types::LeftType; |
208 | 32 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { |
209 | 32 | if (context->enable_strict_mode()) { |
210 | 21 | cast_to_bool = std::make_shared< |
211 | 21 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); |
212 | 21 | } else { |
213 | 11 | cast_to_bool = std::make_shared< |
214 | 11 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); |
215 | 11 | } |
216 | 32 | return true; |
217 | 32 | } else { |
218 | 0 | return false; |
219 | 0 | } |
220 | 32 | }; Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSB_ _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSB_ Line | Count | Source | 205 | 2 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 2 | using Types = std::decay_t<decltype(types)>; | 207 | 2 | using FromDataType = typename Types::LeftType; | 208 | 2 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 2 | if (context->enable_strict_mode()) { | 210 | 1 | cast_to_bool = std::make_shared< | 211 | 1 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 1 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 2 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 2 | }; |
Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSB_ Unexecuted instantiation: _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSB_ _ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSB_ Line | Count | Source | 205 | 12 | auto make_bool_wrapper = [&](const auto& types) -> bool { | 206 | 12 | using Types = std::decay_t<decltype(types)>; | 207 | 12 | using FromDataType = typename Types::LeftType; | 208 | 12 | if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) { | 209 | 12 | if (context->enable_strict_mode()) { | 210 | 11 | cast_to_bool = std::make_shared< | 211 | 11 | CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>(); | 212 | 11 | } else { | 213 | 1 | cast_to_bool = std::make_shared< | 214 | 1 | CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>(); | 215 | 1 | } | 216 | 12 | return true; | 217 | | } else { | 218 | | return false; | 219 | | } | 220 | 12 | }; |
|
221 | | |
222 | 32 | if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_bool_wrapper)) { |
223 | 0 | return create_unsupport_wrapper( |
224 | 0 | fmt::format("CAST AS bool not supported {}", from_type->get_name())); |
225 | 0 | } |
226 | | |
227 | 32 | return [cast_to_bool](FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
228 | 32 | uint32_t result, size_t input_rows_count, |
229 | 32 | const NullMap::value_type* null_map = nullptr) { |
230 | 32 | return cast_to_bool->execute_impl(context, block, arguments, result, input_rows_count, |
231 | 32 | null_map); |
232 | 32 | }; |
233 | 32 | } |
234 | | |
235 | | }; // namespace CastWrapper |
236 | | |
237 | | } // namespace doris |