be/src/format_v2/expr/evolution_cast.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 "format_v2/expr/cast.h" |
21 | | |
22 | | namespace doris::format { |
23 | | |
24 | | // File-to-table conversions own external schema evolution validation; SQL casts do not. |
25 | | class EvolutionCast final : public Cast { |
26 | | ENABLE_FACTORY_CREATOR(EvolutionCast); |
27 | | |
28 | | public: |
29 | | explicit EvolutionCast(const DataTypePtr& type, bool truncate_datetimev2_precision = false, |
30 | | bool strict = false) |
31 | 182 | : Cast(type), |
32 | 182 | _truncate_datetimev2_precision(truncate_datetimev2_precision), |
33 | 182 | _strict(strict) {} |
34 | | |
35 | | Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector, |
36 | | size_t count, ColumnPtr& result_column) const override; |
37 | | std::string debug_string() const override; |
38 | 11 | Status clone_node(VExprSPtr* cloned_expr) const override { |
39 | 11 | DORIS_CHECK(cloned_expr != nullptr); |
40 | 11 | *cloned_expr = |
41 | 11 | EvolutionCast::create_shared(_data_type, _truncate_datetimev2_precision, _strict); |
42 | 11 | return Status::OK(); |
43 | 11 | } |
44 | | |
45 | | protected: |
46 | | void configure_cast_options(CastOptions& options) const override; |
47 | | |
48 | | private: |
49 | | bool _truncate_datetimev2_precision = false; |
50 | | // Fail on every value the target type cannot hold, whatever the session's strict cast mode. |
51 | | // Iceberg equality deletes compare keys after a widening cast, where a non-strict overflow |
52 | | // would turn a key into NULL and match NULL tombstones: a data key TIMESTAMP 1600-01-01 cast |
53 | | // to TIMESTAMP_NS would become NULL and be deleted by a NULL tombstone. |
54 | | bool _strict = false; |
55 | | }; |
56 | | |
57 | | } // namespace doris::format |