be/src/format_v2/expr/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 <string> |
21 | | |
22 | | #include "common/object_pool.h" |
23 | | #include "common/status.h" |
24 | | #include "exprs/function_context.h" |
25 | | #include "exprs/vexpr.h" |
26 | | |
27 | | namespace doris { |
28 | | class RowDescriptor; |
29 | | class RuntimeState; |
30 | | class TExprNode; |
31 | | class Block; |
32 | | class VExprContext; |
33 | | } // namespace doris |
34 | | |
35 | | namespace doris::format { |
36 | | |
37 | | class Cast final : public VExpr { |
38 | | ENABLE_FACTORY_CREATOR(Cast); |
39 | | |
40 | | public: |
41 | 48 | Cast(const DataTypePtr& type) { |
42 | 48 | _node_type = TExprNodeType::CAST_EXPR; |
43 | 48 | _opcode = TExprOpcode::CAST; |
44 | 48 | _data_type = type; |
45 | 48 | } |
46 | 48 | ~Cast() override = default; |
47 | | Status prepare(RuntimeState* state, const RowDescriptor& desc, VExprContext* context) override; |
48 | | Status open(RuntimeState* state, VExprContext* context, |
49 | | FunctionContext::FunctionStateScope scope) override; |
50 | | void close(VExprContext* context, FunctionContext::FunctionStateScope scope) override; |
51 | | Status execute_column_impl(VExprContext* context, const Block* block, const Selector* selector, |
52 | | size_t count, ColumnPtr& result_column) const override; |
53 | | std::string debug_string() const override; |
54 | 0 | uint64_t get_digest(uint64_t seed) const override { return 0; } |
55 | 9 | const std::string& expr_name() const override { return _expr_name; } |
56 | 4 | Status clone_node(VExprSPtr* cloned_expr) const override { |
57 | 4 | DORIS_CHECK(cloned_expr != nullptr); |
58 | 4 | *cloned_expr = Cast::create_shared(_data_type); |
59 | 4 | return Status::OK(); |
60 | 4 | } |
61 | | |
62 | | private: |
63 | | Status _do_execute(VExprContext* context, const Block* block, const Selector* selector, |
64 | | size_t count, ColumnPtr& result_column) const; |
65 | | std::string _expr_name; |
66 | | FunctionBasePtr _function; |
67 | | }; |
68 | | } // namespace doris::format |