Coverage Report

Created: 2026-08-21 00:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format_v2/parquet/parquet_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
//   http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing,
10
// software distributed under the License is distributed on an
11
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12
// KIND, either express or implied.  See the License for the
13
// specific language governing permissions and limitations
14
// under the License.
15
16
#pragma once
17
18
#include <memory>
19
#include <optional>
20
#include <string>
21
#include <vector>
22
23
#include "common/status.h"
24
#include "format_v2/file_reader.h"
25
#include "format_v2/parquet/parquet_column_schema.h"
26
#include "format_v2/parquet/parquet_file_context.h"
27
#include "format_v2/parquet/parquet_profile.h"
28
#include "format_v2/parquet/parquet_scan.h"
29
30
namespace doris {
31
namespace io {
32
struct IOContext;
33
} // namespace io
34
} // namespace doris
35
36
namespace doris::format::parquet {
37
38
struct ParquetReaderScanState;
39
40
namespace detail {
41
bool variant_projection_is_fully_shredded(const tparquet::FileMetaData& metadata,
42
                                          const ParquetColumnSchema& schema,
43
                                          const format::LocalColumnIndex& projection);
44
size_t finalize_variant_leaf_projection(const tparquet::FileMetaData& metadata,
45
                                        const ParquetColumnSchema& schema,
46
                                        format::LocalColumnIndex* projection);
47
} // namespace detail
48
49
// ============================================================================
50
// ============================================================================
51
//   init() -> get_schema() -> open(request) -> get_block() [loop] -> close()
52
// ============================================================================
53
class ParquetReader : public format::FileReader {
54
public:
55
    ParquetReader(std::shared_ptr<io::FileSystemProperties>& system_properties,
56
                  std::unique_ptr<io::FileDescription>& file_description,
57
                  std::shared_ptr<io::IOContext> io_ctx, RuntimeProfile* profile,
58
                  std::optional<format::GlobalRowIdContext> global_rowid_context = std::nullopt,
59
                  bool enable_mapping_timestamp_tz = false, bool enable_mapping_varbinary = false,
60
                  std::string hive_parquet_time_zone = "");
61
    ~ParquetReader() override;
62
63
    Status init(RuntimeState* state) override;
64
65
    void set_batch_size(size_t batch_size) override;
66
67
    Status get_schema(std::vector<format::ColumnDefinition>* file_schema) const override;
68
69
    std::unique_ptr<format::TableColumnMapper> create_column_mapper(
70
            format::TableColumnMapperOptions options) const override;
71
72
    Status open(std::shared_ptr<format::FileScanRequest> request) override;
73
74
1
    bool supports_scan_request_refresh() const override { return true; }
75
76
    Status queue_scan_request(std::shared_ptr<format::FileScanRequest> request) override;
77
78
    Status get_block(Block* file_block, size_t* rows, bool* eof) override;
79
80
    Status get_aggregate_result(const format::FileAggregateRequest& request,
81
                                format::FileAggregateResult* result) override;
82
83
    void set_condition_cache_context(std::shared_ptr<ConditionCacheContext> ctx) override;
84
85
    int64_t get_total_rows() const override;
86
87
    Status close() override;
88
89
protected:
90
    void _init_profile() override;
91
92
private:
93
    void _sync_page_cache_profile();
94
    bool _should_stop() const;
95
    Status _stop_status_if_requested(const Status& status) const;
96
97
    void _fill_column_definition(const ParquetColumnSchema& column_schema,
98
                                 format::ColumnDefinition* field) const;
99
100
    std::unique_ptr<ParquetReaderScanState>
101
            _state;                  // complete scan state (file_context + schema + scheduler)
102
    ParquetProfile _parquet_profile; // RuntimeProfile counter set
103
    ParquetPageCacheStats _reported_page_cache_stats;
104
    std::optional<format::GlobalRowIdContext> _global_rowid_context; // global RowId context
105
    size_t _batch_size = ParquetScanScheduler::DEFAULT_READ_BATCH_SIZE;
106
    bool _enable_mapping_timestamp_tz = false; // whether UTC timestamps are mapped to TIMESTAMPTZ
107
    bool _enable_mapping_varbinary = false;    // whether raw BYTE_ARRAY is mapped to VARBINARY
108
    std::string _hive_parquet_time_zone;       // explicit INT96 timezone; empty disables conversion
109
};
110
111
} // namespace doris::format::parquet