forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhudi_reader.cpp
More file actions
85 lines (74 loc) · 3.67 KB
/
Copy pathhudi_reader.cpp
File metadata and controls
85 lines (74 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "format/table/hudi_reader.h"
#include <vector>
#include "common/status.h"
namespace doris {
// ============================================================================
// HudiParquetReader: on_before_init_reader
// ============================================================================
Status HudiParquetReader::on_before_init_reader(ReaderInitContext* ctx) {
_column_descs = ctx->column_descs;
_fill_col_name_to_block_idx = ctx->col_name_to_block_idx;
RETURN_IF_ERROR(_extract_partition_values(*ctx->range, ctx->tuple_descriptor,
_fill_partition_values,
&_fill_partition_value_is_null));
// Get parquet file metadata schema (file already opened by init_reader)
const FieldDescriptor* field_desc = nullptr;
RETURN_IF_ERROR(get_file_metadata_schema(&field_desc));
DCHECK(field_desc != nullptr);
// Build table_info_node using field_id matching (shared with Paimon/Iceberg)
RETURN_IF_ERROR(gen_table_info_node_by_field_id(
get_scan_params(), get_scan_range().table_format_params.hudi_params.schema_id,
get_tuple_descriptor(), *field_desc));
ctx->table_info_node = table_info_node_ptr;
// Extract column names from descriptors
for (const auto& desc : *ctx->column_descs) {
if (desc.category == ColumnCategory::REGULAR ||
desc.category == ColumnCategory::GENERATED) {
ctx->column_names.push_back(desc.name);
}
}
return Status::OK();
}
// ============================================================================
// HudiOrcReader: on_before_init_reader
// ============================================================================
Status HudiOrcReader::on_before_init_reader(ReaderInitContext* ctx) {
_column_descs = ctx->column_descs;
_fill_col_name_to_block_idx = ctx->col_name_to_block_idx;
RETURN_IF_ERROR(_extract_partition_values(*ctx->range, ctx->tuple_descriptor,
_fill_partition_values,
&_fill_partition_value_is_null));
// Get ORC file type (file already opened by init_reader)
const orc::Type* orc_type_ptr = nullptr;
RETURN_IF_ERROR(get_file_type(&orc_type_ptr));
// Build table_info_node using field_id matching
RETURN_IF_ERROR(gen_table_info_node_by_field_id(
get_scan_params(), get_scan_range().table_format_params.hudi_params.schema_id,
get_tuple_descriptor(), orc_type_ptr));
ctx->table_info_node = table_info_node_ptr;
// Extract column names from descriptors
for (const auto& desc : *ctx->column_descs) {
if (desc.category == ColumnCategory::REGULAR ||
desc.category == ColumnCategory::GENERATED) {
ctx->column_names.push_back(desc.name);
}
}
return Status::OK();
}
} // namespace doris