be/src/exprs/function/cast/cast_to_uuid.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/column/column_nullable.h" |
21 | | #include "core/data_type/data_type_string.h" |
22 | | #include "core/data_type/data_type_uuid.h" |
23 | | #include "exprs/function/cast/cast_base.h" |
24 | | |
25 | | namespace doris { |
26 | | |
27 | | struct CastToUUID { |
28 | 0 | static bool from_string(const StringRef& from, UUIDValueType& to, CastParameters&) { |
29 | 0 | return UUIDValue::from_string(to, from.data, from.size); |
30 | 0 | } |
31 | | }; |
32 | | |
33 | | template <CastModeType Mode> |
34 | | class CastToImpl<Mode, DataTypeString, DataTypeUUID> : public CastToBase { |
35 | | public: |
36 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
37 | | uint32_t result, size_t input_rows_count, |
38 | 2 | const NullMap::value_type* null_map = nullptr) const override { |
39 | 2 | const auto& column_from = |
40 | 2 | assert_cast<const ColumnString&>(*block.get_by_position(arguments[0]).column); |
41 | 2 | const auto nested_to_type = remove_nullable(block.get_by_position(result).type); |
42 | 2 | const auto serde = nested_to_type->get_serde(); |
43 | | |
44 | 2 | if constexpr (Mode == CastModeType::NonStrictMode) { |
45 | 2 | auto column_to = create_empty_nullable_column(nested_to_type); |
46 | 2 | RETURN_IF_ERROR(serde->from_string_batch(column_from, *column_to, {})); |
47 | 2 | block.get_by_position(result).column = std::move(column_to); |
48 | 2 | } else { |
49 | 0 | auto column_to = nested_to_type->create_column(); |
50 | 0 | RETURN_IF_ERROR( |
51 | 0 | serde->from_string_strict_mode_batch(column_from, *column_to, {}, null_map)); |
52 | 0 | block.get_by_position(result).column = std::move(column_to); |
53 | 0 | } |
54 | 0 | return Status::OK(); |
55 | 2 | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_12DataTypeUUIDEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_12DataTypeUUIDEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh Line | Count | Source | 38 | 2 | const NullMap::value_type* null_map = nullptr) const override { | 39 | 2 | const auto& column_from = | 40 | 2 | assert_cast<const ColumnString&>(*block.get_by_position(arguments[0]).column); | 41 | 2 | const auto nested_to_type = remove_nullable(block.get_by_position(result).type); | 42 | 2 | const auto serde = nested_to_type->get_serde(); | 43 | | | 44 | 2 | if constexpr (Mode == CastModeType::NonStrictMode) { | 45 | 2 | auto column_to = create_empty_nullable_column(nested_to_type); | 46 | 2 | RETURN_IF_ERROR(serde->from_string_batch(column_from, *column_to, {})); | 47 | 2 | block.get_by_position(result).column = std::move(column_to); | 48 | | } else { | 49 | | auto column_to = nested_to_type->create_column(); | 50 | | RETURN_IF_ERROR( | 51 | | serde->from_string_strict_mode_batch(column_from, *column_to, {}, null_map)); | 52 | | block.get_by_position(result).column = std::move(column_to); | 53 | | } | 54 | 0 | return Status::OK(); | 55 | 2 | } |
|
56 | | }; |
57 | | |
58 | | } // namespace doris |