be/src/exprs/vstruct_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/vstruct_literal.h" |
19 | | |
20 | | #include <memory> |
21 | | #include <vector> |
22 | | |
23 | | #include "core/column/column.h" |
24 | | #include "core/data_type/data_type.h" |
25 | | #include "core/field.h" |
26 | | #include "exprs/vexpr.h" |
27 | | |
28 | | namespace doris { |
29 | | class RowDescriptor; |
30 | | class RuntimeState; |
31 | | class VExprContext; |
32 | | } // namespace doris |
33 | | |
34 | | namespace doris { |
35 | | |
36 | | Status VStructLiteral::prepare(RuntimeState* state, const RowDescriptor& row_desc, |
37 | 1.57k | VExprContext* context) { |
38 | 1.57k | RETURN_IF_ERROR_OR_PREPARED(VExpr::prepare(state, row_desc, context)); |
39 | 1.57k | Field struct_field = Field::create_field<TYPE_STRUCT>(Tuple()); |
40 | 5.24k | for (const auto& child : _children) { |
41 | 5.24k | Field item; |
42 | 5.24k | auto child_literal = std::dynamic_pointer_cast<const VLiteral>(child); |
43 | 5.24k | child_literal->get_column_ptr()->get(0, item); |
44 | 5.24k | struct_field.get<TYPE_STRUCT>().push_back(item); |
45 | 5.24k | } |
46 | 1.57k | _column_ptr = _data_type->create_column_const(1, struct_field); |
47 | 1.57k | return Status::OK(); |
48 | 1.57k | } |
49 | | |
50 | | } // namespace doris |