Coverage Report

Created: 2026-04-20 14:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/iceberg_reader.h
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
#pragma once
19
20
#include <cstddef>
21
#include <cstdint>
22
#include <string>
23
#include <unordered_map>
24
#include <unordered_set>
25
#include <utility>
26
#include <vector>
27
28
#include "common/status.h"
29
#include "core/column/column_dictionary.h"
30
#include "core/data_type/define_primitive_type.h"
31
#include "core/data_type/primitive_type.h"
32
#include "core/types.h"
33
#include "format/orc/vorc_reader.h"
34
#include "format/parquet/vparquet_reader.h"
35
#include "format/table/iceberg_reader_mixin.h"
36
#include "storage/olap_common.h"
37
38
namespace tparquet {
39
class KeyValue;
40
class ColumnMetaData;
41
} // namespace tparquet
42
43
namespace doris {
44
class RowDescriptor;
45
class RuntimeState;
46
class SlotDescriptor;
47
class TFileRangeDesc;
48
class TFileScanRangeParams;
49
class TIcebergDeleteFileDesc;
50
class TupleDescriptor;
51
52
namespace io {
53
struct IOContext;
54
} // namespace io
55
template <typename T>
56
class ColumnStr;
57
using ColumnString = ColumnStr<UInt32>;
58
class Block;
59
class GenericReader;
60
class ShardedKVCache;
61
class VExprContext;
62
63
struct IcebergTableReader {
64
    static bool _is_fully_dictionary_encoded(const tparquet::ColumnMetaData& column_metadata);
65
};
66
67
// IcebergParquetReader: inherits ParquetReader via IcebergReaderMixin CRTP
68
class IcebergParquetReader final : public IcebergReaderMixin<ParquetReader> {
69
public:
70
    ENABLE_FACTORY_CREATOR(IcebergParquetReader);
71
72
    IcebergParquetReader(ShardedKVCache* kv_cache, RuntimeProfile* profile,
73
                         const TFileScanRangeParams& params, const TFileRangeDesc& range,
74
                         size_t batch_size, const cctz::time_zone* ctz, io::IOContext* io_ctx,
75
                         RuntimeState* state, FileMetaCache* meta_cache)
76
7
            : IcebergReaderMixin<ParquetReader>(kv_cache, profile, params, range, batch_size, ctz,
77
7
                                                io_ctx, state, meta_cache) {}
78
79
0
    void set_delete_rows() final {
80
        // Call ParquetReader's set_delete_rows(const vector<int64_t>*)
81
0
        ParquetReader::set_delete_rows(_iceberg_delete_rows);
82
0
    }
83
84
protected:
85
    // Parquet-specific schema matching via on_before_init_reader hook
86
    Status on_before_init_reader(ReaderInitContext* ctx) override;
87
88
    std::unique_ptr<GenericReader> _create_equality_reader(
89
0
            const TFileRangeDesc& delete_desc) final {
90
0
        return ParquetReader::create_unique(this->get_profile(), this->get_scan_params(),
91
0
                                            delete_desc, READ_DELETE_FILE_BATCH_SIZE,
92
0
                                            &this->get_state()->timezone_obj(), this->get_io_ctx(),
93
0
                                            this->get_state(), this->_meta_cache);
94
0
    }
95
96
    static ColumnIdResult _create_column_ids(const FieldDescriptor* field_desc,
97
                                             const TupleDescriptor* tuple_descriptor);
98
99
private:
100
    Status _read_position_delete_file(const TFileRangeDesc* delete_range,
101
                                      DeleteFile* position_delete) final;
102
};
103
104
// IcebergOrcReader: inherits OrcReader via IcebergReaderMixin CRTP
105
class IcebergOrcReader final : public IcebergReaderMixin<OrcReader> {
106
public:
107
    ENABLE_FACTORY_CREATOR(IcebergOrcReader);
108
109
    IcebergOrcReader(ShardedKVCache* kv_cache, RuntimeProfile* profile, RuntimeState* state,
110
                     const TFileScanRangeParams& params, const TFileRangeDesc& range,
111
                     size_t batch_size, const std::string& ctz, io::IOContext* io_ctx,
112
                     FileMetaCache* meta_cache)
113
7
            : IcebergReaderMixin<OrcReader>(kv_cache, profile, state, params, range, batch_size,
114
7
                                            ctz, io_ctx, meta_cache) {}
115
116
0
    void set_delete_rows() final {
117
        // Call OrcReader's set_position_delete_rowids
118
0
        this->set_position_delete_rowids(_iceberg_delete_rows);
119
0
    }
120
121
protected:
122
    // ORC-specific schema matching via on_before_init_reader hook
123
    Status on_before_init_reader(ReaderInitContext* ctx) override;
124
125
    std::unique_ptr<GenericReader> _create_equality_reader(
126
0
            const TFileRangeDesc& delete_desc) override {
127
0
        return OrcReader::create_unique(this->get_profile(), this->get_state(),
128
0
                                        this->get_scan_params(), delete_desc,
129
0
                                        READ_DELETE_FILE_BATCH_SIZE, this->get_state()->timezone(),
130
0
                                        this->get_io_ctx(), this->_meta_cache);
131
0
    }
132
133
    static ColumnIdResult _create_column_ids(const orc::Type* orc_type,
134
                                             const TupleDescriptor* tuple_descriptor);
135
136
    static const std::string ICEBERG_ORC_ATTRIBUTE;
137
138
private:
139
    Status _read_position_delete_file(const TFileRangeDesc* delete_range,
140
                                      DeleteFile* position_delete) final;
141
};
142
143
} // namespace doris