be/src/format/table/hudi_reader.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 "format/table/hudi_reader.h" |
19 | | |
20 | | #include <vector> |
21 | | |
22 | | #include "common/status.h" |
23 | | |
24 | | namespace doris { |
25 | | #include "common/compile_check_begin.h" |
26 | | |
27 | | // ============================================================================ |
28 | | // HudiParquetReader: on_before_init_reader |
29 | | // ============================================================================ |
30 | 0 | Status HudiParquetReader::on_before_init_reader(ReaderInitContext* ctx) { |
31 | 0 | _column_descs = ctx->column_descs; |
32 | 0 | _fill_col_name_to_block_idx = ctx->col_name_to_block_idx; |
33 | | // Get parquet file metadata schema (file already opened by init_reader) |
34 | 0 | const FieldDescriptor* field_desc = nullptr; |
35 | 0 | RETURN_IF_ERROR(get_file_metadata_schema(&field_desc)); |
36 | 0 | DCHECK(field_desc != nullptr); |
37 | | |
38 | | // Build table_info_node using field_id matching (shared with Paimon/Iceberg) |
39 | 0 | RETURN_IF_ERROR(gen_table_info_node_by_field_id( |
40 | 0 | get_scan_params(), get_scan_range().table_format_params.hudi_params.schema_id, |
41 | 0 | get_tuple_descriptor(), *field_desc)); |
42 | 0 | ctx->table_info_node = table_info_node_ptr; |
43 | | |
44 | | // Extract column names from descriptors |
45 | 0 | for (const auto& desc : *ctx->column_descs) { |
46 | 0 | if (desc.category == ColumnCategory::REGULAR || |
47 | 0 | desc.category == ColumnCategory::GENERATED) { |
48 | 0 | ctx->column_names.push_back(desc.name); |
49 | 0 | } |
50 | 0 | } |
51 | 0 | return Status::OK(); |
52 | 0 | } |
53 | | |
54 | | // ============================================================================ |
55 | | // HudiOrcReader: on_before_init_reader |
56 | | // ============================================================================ |
57 | 0 | Status HudiOrcReader::on_before_init_reader(ReaderInitContext* ctx) { |
58 | 0 | _column_descs = ctx->column_descs; |
59 | 0 | _fill_col_name_to_block_idx = ctx->col_name_to_block_idx; |
60 | | // Get ORC file type (file already opened by init_reader) |
61 | 0 | const orc::Type* orc_type_ptr = nullptr; |
62 | 0 | RETURN_IF_ERROR(get_file_type(&orc_type_ptr)); |
63 | | |
64 | | // Build table_info_node using field_id matching |
65 | 0 | RETURN_IF_ERROR(gen_table_info_node_by_field_id( |
66 | 0 | get_scan_params(), get_scan_range().table_format_params.hudi_params.schema_id, |
67 | 0 | get_tuple_descriptor(), orc_type_ptr)); |
68 | 0 | ctx->table_info_node = table_info_node_ptr; |
69 | | |
70 | | // Extract column names from descriptors |
71 | 0 | for (const auto& desc : *ctx->column_descs) { |
72 | 0 | if (desc.category == ColumnCategory::REGULAR || |
73 | 0 | desc.category == ColumnCategory::GENERATED) { |
74 | 0 | ctx->column_names.push_back(desc.name); |
75 | 0 | } |
76 | 0 | } |
77 | 0 | return Status::OK(); |
78 | 0 | } |
79 | | |
80 | | #include "common/compile_check_end.h" |
81 | | } // namespace doris |