Coverage Report

Created: 2026-04-22 11:46

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