/root/doris/be/src/exprs/varray_literal.cpp
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 | | #include "exprs/varray_literal.h" |
19 | | |
20 | | #include <gen_cpp/Exprs_types.h> |
21 | | #include <glog/logging.h> |
22 | | |
23 | | #include <memory> |
24 | | #include <ostream> |
25 | | #include <vector> |
26 | | |
27 | | #include "core/column/column.h" |
28 | | #include "core/data_type/data_type.h" |
29 | | #include "core/field.h" |
30 | | #include "exprs/vexpr.h" |
31 | | |
32 | | namespace doris { |
33 | | class RowDescriptor; |
34 | | class RuntimeState; |
35 | | class VExprContext; |
36 | | } // namespace doris |
37 | | |
38 | | namespace doris { |
39 | | |
40 | | Status VArrayLiteral::prepare(RuntimeState* state, const RowDescriptor& row_desc, |
41 | 9 | VExprContext* context) { |
42 | 9 | RETURN_IF_ERROR_OR_PREPARED(VExpr::prepare(state, row_desc, context)); |
43 | 9 | bool is_null = (_node_type == TExprNodeType::NULL_LITERAL); |
44 | 9 | Field array = is_null ? Field() : Field::create_field<TYPE_ARRAY>(Array()); |
45 | 72 | for (auto& child : _children) { |
46 | 72 | Field item; |
47 | 72 | auto child_literal = std::dynamic_pointer_cast<const VLiteral>(child); |
48 | 72 | child_literal->get_column_ptr()->get(0, item); |
49 | 72 | array.get<TYPE_ARRAY>().push_back(item); |
50 | 72 | } |
51 | 9 | _column_ptr = _data_type->create_column_const(1, array); |
52 | 9 | return Status::OK(); |
53 | 9 | } |
54 | | |
55 | | } // namespace doris |