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(RuntimeState* /*state*/, const ColumnWithTypeAndName& source_column, |
37 | | ColumnWithTypeAndName& target_column, size_t /*input_rows_count*/, |
38 | 2 | const NullMap::value_type* parent_null_map = nullptr) const override { |
39 | 2 | const auto& column_from = assert_cast<const ColumnString&>(*source_column.column); |
40 | 2 | const auto nested_to_type = remove_nullable(target_column.type); |
41 | 2 | const auto serde = nested_to_type->get_serde(); |
42 | | |
43 | 2 | if constexpr (Mode == CastModeType::NonStrictMode) { |
44 | 2 | auto column_to = create_empty_nullable_column(nested_to_type); |
45 | 2 | RETURN_IF_ERROR(serde->from_string_batch(column_from, *column_to, {})); |
46 | 2 | target_column.column = std::move(column_to); |
47 | 2 | } else { |
48 | 0 | auto column_to = nested_to_type->create_column(); |
49 | 0 | RETURN_IF_ERROR(serde->from_string_strict_mode_batch(column_from, *column_to, {}, |
50 | 0 | parent_null_map)); |
51 | 0 | target_column.column = std::move(column_to); |
52 | 0 | } |
53 | 0 | return Status::OK(); |
54 | 2 | } Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_12DataTypeUUIDEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS7_mPKh _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_12DataTypeUUIDEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS7_mPKh Line | Count | Source | 38 | 2 | const NullMap::value_type* parent_null_map = nullptr) const override { | 39 | 2 | const auto& column_from = assert_cast<const ColumnString&>(*source_column.column); | 40 | 2 | const auto nested_to_type = remove_nullable(target_column.type); | 41 | 2 | const auto serde = nested_to_type->get_serde(); | 42 | | | 43 | 2 | if constexpr (Mode == CastModeType::NonStrictMode) { | 44 | 2 | auto column_to = create_empty_nullable_column(nested_to_type); | 45 | 2 | RETURN_IF_ERROR(serde->from_string_batch(column_from, *column_to, {})); | 46 | 2 | target_column.column = std::move(column_to); | 47 | | } else { | 48 | | auto column_to = nested_to_type->create_column(); | 49 | | RETURN_IF_ERROR(serde->from_string_strict_mode_batch(column_from, *column_to, {}, | 50 | | parent_null_map)); | 51 | | target_column.column = std::move(column_to); | 52 | | } | 53 | 0 | return Status::OK(); | 54 | 2 | } |
|
55 | | }; |
56 | | |
57 | | } // namespace doris |