Coverage Report

Created: 2026-07-12 15:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format_v2/table_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_v2/table_reader.h"
19
20
#include <gen_cpp/ExternalTableSchema_types.h>
21
#include <gen_cpp/PlanNodes_types.h>
22
#include <gen_cpp/Types_types.h>
23
24
#include <algorithm>
25
#include <memory>
26
#include <ranges>
27
#include <set>
28
#include <sstream>
29
#include <utility>
30
#include <vector>
31
32
#include "common/cast_set.h"
33
#include "common/status.h"
34
#include "core/assert_cast.h"
35
#include "core/data_type/data_type_array.h"
36
#include "core/data_type/data_type_map.h"
37
#include "core/data_type/data_type_struct.h"
38
#include "exprs/vexpr_context.h"
39
#include "exprs/vslot_ref.h"
40
#include "format/table/deletion_vector_reader.h"
41
#include "format/table/iceberg_delete_file_reader_helper.h"
42
#include "format/table/paimon_reader.h"
43
#include "format_v2/column_mapper.h"
44
#include "format_v2/delimited_text/csv_reader.h"
45
#include "format_v2/delimited_text/text_reader.h"
46
#include "format_v2/json/json_reader.h"
47
#include "format_v2/native/native_reader.h"
48
#include "format_v2/orc/orc_reader.h"
49
#include "format_v2/parquet/parquet_reader.h"
50
#include "storage/segment/condition_cache.h"
51
#include "util/debug_points.h"
52
#include "util/string_util.h"
53
54
namespace doris::format {
55
namespace {
56
57
template <typename T, typename Formatter>
58
61
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
61
    std::ostringstream out;
60
61
    out << "[";
61
70
    for (size_t i = 0; i < values.size(); ++i) {
62
9
        if (i > 0) {
63
3
            out << ", ";
64
3
        }
65
9
        out << formatter(values[i]);
66
9
    }
67
61
    out << "]";
68
61
    return out.str();
69
61
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_16ColumnDefinitionEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_0EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Line
Count
Source
58
12
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
12
    std::ostringstream out;
60
12
    out << "[";
61
14
    for (size_t i = 0; i < values.size(); ++i) {
62
2
        if (i > 0) {
63
1
            out << ", ";
64
1
        }
65
2
        out << formatter(values[i]);
66
2
    }
67
12
    out << "]";
68
12
    return out.str();
69
12
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11TableFilterEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_1EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Line
Count
Source
58
12
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
12
    std::ostringstream out;
60
12
    out << "[";
61
13
    for (size_t i = 0; i < values.size(); ++i) {
62
1
        if (i > 0) {
63
0
            out << ", ";
64
0
        }
65
1
        out << formatter(values[i]);
66
1
    }
67
12
    out << "]";
68
12
    return out.str();
69
12
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11GlobalIndexEZNS1_25table_filter_debug_stringB5cxx11ERKNS0_11TableFilterEE3$_0EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISF_EET0_
Line
Count
Source
58
1
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
1
    std::ostringstream out;
60
1
    out << "[";
61
2
    for (size_t i = 0; i < values.size(); ++i) {
62
1
        if (i > 0) {
63
0
            out << ", ";
64
0
        }
65
1
        out << formatter(values[i]);
66
1
    }
67
1
    out << "]";
68
1
    return out.str();
69
1
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsISt10shared_ptrINS_12VExprContextEEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_2EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISF_EET0_
Line
Count
Source
58
12
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
12
    std::ostringstream out;
60
12
    out << "[";
61
13
    for (size_t i = 0; i < values.size(); ++i) {
62
1
        if (i > 0) {
63
0
            out << ", ";
64
0
        }
65
1
        out << formatter(values[i]);
66
1
    }
67
12
    out << "]";
68
12
    return out.str();
69
12
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_16ColumnDefinitionEZNKS0_11TableReader12debug_stringB5cxx11EvE3$_3EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Line
Count
Source
58
12
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
12
    std::ostringstream out;
60
12
    out << "[";
61
14
    for (size_t i = 0; i < values.size(); ++i) {
62
2
        if (i > 0) {
63
1
            out << ", ";
64
1
        }
65
2
        out << formatter(values[i]);
66
2
    }
67
12
    out << "]";
68
12
    return out.str();
69
12
}
table_reader.cpp:_ZN5doris6format12_GLOBAL__N_131join_table_reader_debug_stringsINS0_11TableReader15FileBlockColumnEZNKS3_12debug_stringB5cxx11EvE3$_4EENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIT_SaISD_EET0_
Line
Count
Source
58
12
std::string join_table_reader_debug_strings(const std::vector<T>& values, Formatter formatter) {
59
12
    std::ostringstream out;
60
12
    out << "[";
61
14
    for (size_t i = 0; i < values.size(); ++i) {
62
2
        if (i > 0) {
63
1
            out << ", ";
64
1
        }
65
2
        out << formatter(values[i]);
66
2
    }
67
12
    out << "]";
68
12
    return out.str();
69
12
}
70
71
12
std::string file_format_to_string(FileFormat format) {
72
12
    switch (format) {
73
5
    case FileFormat::PARQUET:
74
5
        return "PARQUET";
75
1
    case FileFormat::ORC:
76
1
        return "ORC";
77
1
    case FileFormat::CSV:
78
1
        return "CSV";
79
1
    case FileFormat::JSON:
80
1
        return "JSON";
81
1
    case FileFormat::TEXT:
82
1
        return "TEXT";
83
1
    case FileFormat::JNI:
84
1
        return "JNI";
85
1
    case FileFormat::NATIVE:
86
1
        return "NATIVE";
87
1
    case FileFormat::ARROW:
88
1
        return "ARROW";
89
12
    }
90
0
    return "UNKNOWN";
91
12
}
92
93
12
std::string push_down_agg_to_string(TPushAggOp::type op) {
94
12
    switch (op) {
95
8
    case TPushAggOp::NONE:
96
8
        return "NONE";
97
1
    case TPushAggOp::COUNT:
98
1
        return "COUNT";
99
1
    case TPushAggOp::MINMAX:
100
1
        return "MINMAX";
101
1
    case TPushAggOp::MIX:
102
1
        return "MIX";
103
1
    case TPushAggOp::COUNT_ON_INDEX:
104
1
        return "COUNT_ON_INDEX";
105
12
    }
106
0
    return "UNKNOWN";
107
12
}
108
109
12
std::string current_file_debug_string(const std::unique_ptr<ScanTask>& task) {
110
12
    if (task == nullptr || task->data_file == nullptr) {
111
11
        return "null";
112
11
    }
113
1
    const auto& file = *task->data_file;
114
1
    std::ostringstream out;
115
1
    out << "FileDescription{path=" << file.path << ", file_size=" << file.file_size
116
1
        << ", range_start_offset=" << file.range_start_offset << ", range_size=" << file.range_size
117
1
        << ", mtime=" << file.mtime << ", fs_name=" << file.fs_name
118
1
        << ", file_cache_admission=" << file.file_cache_admission << "}";
119
1
    return out.str();
120
12
}
121
122
12
std::string partition_values_debug_string(const std::map<std::string, Field>& partition_values) {
123
12
    std::ostringstream out;
124
12
    out << "{";
125
12
    size_t idx = 0;
126
12
    for (const auto& [key, _] : partition_values) {
127
1
        if (idx++ > 0) {
128
0
            out << ", ";
129
0
        }
130
1
        out << key;
131
1
    }
132
12
    out << "}";
133
12
    return out.str();
134
12
}
135
136
6
const schema::external::TField* get_field_ptr(const schema::external::TFieldPtr& field_ptr) {
137
6
    if (!field_ptr.__isset.field_ptr || field_ptr.field_ptr == nullptr) {
138
0
        return nullptr;
139
0
    }
140
6
    return field_ptr.field_ptr.get();
141
6
}
142
143
4
bool external_field_matches_name(const schema::external::TField& field, const std::string& name) {
144
4
    if (field.__isset.name && to_lower(field.name) == to_lower(name)) {
145
0
        return true;
146
0
    }
147
4
    return field.__isset.name_mapping &&
148
4
           std::ranges::any_of(field.name_mapping, [&](const std::string& alias) {
149
4
               return to_lower(alias) == to_lower(name);
150
4
           });
151
4
}
152
153
DataTypePtr find_struct_child_type_by_external_field(const DataTypeStruct& struct_type,
154
2
                                                     const schema::external::TField& field) {
155
3
    for (size_t field_idx = 0; field_idx < struct_type.get_elements().size(); ++field_idx) {
156
3
        if (external_field_matches_name(field, struct_type.get_element_name(field_idx))) {
157
2
            return struct_type.get_element(field_idx);
158
2
        }
159
3
    }
160
0
    return nullptr;
161
2
}
162
163
ColumnDefinition build_schema_column_from_external_field(const schema::external::TField& field,
164
6
                                                         DataTypePtr type) {
165
6
    ColumnDefinition column {
166
6
            .identifier = field.__isset.id ? Field::create_field<TYPE_INT>(field.id) : Field {},
167
6
            .name = field.__isset.name ? field.name : "",
168
6
            .name_mapping =
169
6
                    field.__isset.name_mapping ? field.name_mapping : std::vector<std::string> {},
170
6
            .type = std::move(type),
171
6
            .children = {},
172
6
            .default_expr = nullptr,
173
6
            .is_partition_key = false,
174
6
    };
175
6
    if (column.type == nullptr || !field.__isset.nestedField) {
176
3
        return column;
177
3
    }
178
179
3
    const auto nested_type = remove_nullable(column.type);
180
3
    switch (nested_type->get_primitive_type()) {
181
1
    case TYPE_STRUCT: {
182
1
        if (!field.nestedField.__isset.struct_field ||
183
1
            !field.nestedField.struct_field.__isset.fields) {
184
0
            return column;
185
0
        }
186
1
        const auto& struct_type = assert_cast<const DataTypeStruct&>(*nested_type);
187
2
        for (const auto& child_ptr : field.nestedField.struct_field.fields) {
188
2
            const auto* child_field = get_field_ptr(child_ptr);
189
2
            if (child_field == nullptr || !child_field->__isset.name) {
190
0
                continue;
191
0
            }
192
2
            auto child_type = find_struct_child_type_by_external_field(struct_type, *child_field);
193
2
            if (child_type == nullptr) {
194
0
                continue;
195
0
            }
196
2
            column.children.push_back(
197
2
                    build_schema_column_from_external_field(*child_field, child_type));
198
2
        }
199
1
        break;
200
1
    }
201
1
    case TYPE_ARRAY: {
202
1
        if (!field.nestedField.__isset.array_field ||
203
1
            !field.nestedField.array_field.__isset.item_field) {
204
0
            return column;
205
0
        }
206
1
        const auto* item_field = get_field_ptr(field.nestedField.array_field.item_field);
207
1
        if (item_field == nullptr) {
208
0
            return column;
209
0
        }
210
1
        const auto& array_type = assert_cast<const DataTypeArray&>(*nested_type);
211
1
        auto child =
212
1
                build_schema_column_from_external_field(*item_field, array_type.get_nested_type());
213
1
        child.name = "element";
214
1
        if (child.has_identifier_name()) {
215
0
            child.identifier = Field::create_field<TYPE_STRING>(child.name);
216
0
        }
217
1
        column.children.push_back(std::move(child));
218
1
        break;
219
1
    }
220
1
    case TYPE_MAP: {
221
1
        if (!field.nestedField.__isset.map_field ||
222
1
            !field.nestedField.map_field.__isset.key_field ||
223
1
            !field.nestedField.map_field.__isset.value_field) {
224
0
            return column;
225
0
        }
226
1
        const auto& map_type = assert_cast<const DataTypeMap&>(*nested_type);
227
1
        const auto* key_field = get_field_ptr(field.nestedField.map_field.key_field);
228
1
        if (key_field != nullptr) {
229
1
            auto child =
230
1
                    build_schema_column_from_external_field(*key_field, map_type.get_key_type());
231
1
            child.name = "key";
232
1
            if (child.has_identifier_name()) {
233
0
                child.identifier = Field::create_field<TYPE_STRING>(child.name);
234
0
            }
235
1
            column.children.push_back(std::move(child));
236
1
        }
237
1
        const auto* value_field = get_field_ptr(field.nestedField.map_field.value_field);
238
1
        if (value_field != nullptr) {
239
1
            auto child = build_schema_column_from_external_field(*value_field,
240
1
                                                                 map_type.get_value_type());
241
1
            child.name = "value";
242
1
            if (child.has_identifier_name()) {
243
0
                child.identifier = Field::create_field<TYPE_STRING>(child.name);
244
0
            }
245
1
            column.children.push_back(std::move(child));
246
1
        }
247
1
        break;
248
1
    }
249
0
    default:
250
0
        break;
251
3
    }
252
3
    return column;
253
3
}
254
255
const schema::external::TField* find_external_root_field(const TFileScanRangeParams* params,
256
8
                                                         const ColumnDefinition& column) {
257
8
    if (params == nullptr || !params->__isset.history_schema_info ||
258
8
        params->history_schema_info.empty()) {
259
7
        return nullptr;
260
7
    }
261
1
    const auto* schema = &params->history_schema_info.front();
262
1
    if (params->__isset.current_schema_id) {
263
2
        for (const auto& candidate_schema : params->history_schema_info) {
264
2
            if (candidate_schema.__isset.schema_id &&
265
2
                candidate_schema.schema_id == params->current_schema_id) {
266
1
                schema = &candidate_schema;
267
1
                break;
268
1
            }
269
2
        }
270
1
    }
271
1
    if (!schema->__isset.root_field || !schema->root_field.__isset.fields) {
272
0
        return nullptr;
273
0
    }
274
1
    for (const auto& field_ptr : schema->root_field.fields) {
275
1
        const auto* field = get_field_ptr(field_ptr);
276
1
        if (field == nullptr) {
277
0
            continue;
278
0
        }
279
1
        if (external_field_matches_name(*field, column.name)) {
280
1
            return field;
281
1
        }
282
1
    }
283
0
    return nullptr;
284
1
}
285
286
2
std::string expr_context_debug_string(const VExprContextSPtr& context) {
287
2
    if (context == nullptr) {
288
0
        return "null";
289
0
    }
290
2
    const auto root = context->root();
291
2
    if (root == nullptr) {
292
0
        return "VExprContext{root=null}";
293
0
    }
294
2
    std::ostringstream out;
295
2
    out << "VExprContext{root_name=" << root->expr_name() << ", root_debug=" << root->debug_string()
296
2
        << "}";
297
2
    return out.str();
298
2
}
299
300
1
std::string table_filter_debug_string(const TableFilter& filter) {
301
1
    std::ostringstream out;
302
1
    out << "TableFilter{conjunct=" << expr_context_debug_string(filter.conjunct)
303
1
        << ", global_indices="
304
1
        << join_table_reader_debug_strings(
305
1
                   filter.global_indices,
306
1
                   [](GlobalIndex global_index) { return std::to_string(global_index.value()); })
307
1
        << "}";
308
1
    return out.str();
309
1
}
310
311
3
bool contains_runtime_filter(const VExprContextSPtrs& conjuncts) {
312
3
    return std::ranges::any_of(conjuncts, [](const auto& conjunct) {
313
3
        return conjunct != nullptr && conjunct->root() != nullptr &&
314
3
               conjunct->root()->is_rf_wrapper();
315
3
    });
316
3
}
317
318
87
void collect_global_indices(const VExprSPtr& expr, std::set<GlobalIndex>* global_indices) {
319
87
    if (expr == nullptr) {
320
0
        return;
321
0
    }
322
87
    if (expr->is_rf_wrapper()) {
323
        // RuntimeFilterExpr wraps a real predicate expression but its own thrift node can still
324
        // look like SLOT_REF. Collect indices from the wrapped predicate; do not cast the wrapper
325
        // itself to VSlotRef.
326
4
        collect_global_indices(expr->get_impl(), global_indices);
327
4
        return;
328
4
    }
329
83
    if (expr->is_slot_ref()) {
330
28
        const auto* slot_ref = assert_cast<const VSlotRef*>(expr.get());
331
28
        DORIS_CHECK(slot_ref->column_id() >= 0);
332
28
        global_indices->insert(GlobalIndex(cast_set<size_t>(slot_ref->column_id())));
333
28
    }
334
83
    for (const auto& child : expr->children()) {
335
56
        collect_global_indices(child, global_indices);
336
56
    }
337
83
}
338
339
Status build_table_filters_from_conjunct(const VExprContextSPtr& conjunct, RuntimeState* state,
340
25
                                         std::vector<TableFilter>* table_filters) {
341
25
    if (conjunct == nullptr) {
342
0
        return Status::OK();
343
0
    }
344
25
    std::set<GlobalIndex> global_indices;
345
25
    collect_global_indices(conjunct->root(), &global_indices);
346
25
    if (!global_indices.empty()) {
347
25
        TableFilter table_filter;
348
25
        VExprSPtr filter_root;
349
25
        RETURN_IF_ERROR(clone_table_expr_tree(conjunct->root(), &filter_root));
350
25
        table_filter.conjunct = VExprContext::create_shared(std::move(filter_root));
351
26
        for (const auto global_index : global_indices) {
352
26
            table_filter.global_indices.push_back(global_index);
353
26
        }
354
25
        table_filters->push_back(std::move(table_filter));
355
25
    }
356
25
    return Status::OK();
357
25
}
358
359
Status parse_deletion_vector(const char* buf, size_t buffer_size, DeleteFileDesc::Format format,
360
5
                             DeletionVector* deletion_vector) {
361
5
    DORIS_CHECK(buf != nullptr);
362
5
    DORIS_CHECK(deletion_vector != nullptr);
363
5
    DORIS_CHECK(format == DeleteFileDesc::Format::PAIMON ||
364
5
                format == DeleteFileDesc::Format::ICEBERG);
365
366
5
    if (format == DeleteFileDesc::Format::PAIMON) {
367
1
        RETURN_IF_ERROR(decode_paimon_deletion_vector_buffer(buf, buffer_size, deletion_vector));
368
1
        return Status::OK();
369
1
    }
370
371
4
    return decode_iceberg_deletion_vector_buffer(buf, buffer_size, deletion_vector);
372
5
}
373
374
} // namespace
375
376
std::shared_ptr<io::FileSystemProperties> create_system_properties(
377
99
        const TFileScanRangeParams* scan_params) {
378
99
    auto system_properties = std::make_shared<io::FileSystemProperties>();
379
99
    if (scan_params == nullptr || !scan_params->__isset.file_type) {
380
79
        system_properties->system_type = TFileType::FILE_LOCAL;
381
79
        return system_properties;
382
79
    }
383
20
    system_properties->system_type = scan_params->file_type;
384
20
    system_properties->properties = scan_params->properties;
385
20
    system_properties->hdfs_params = scan_params->hdfs_params;
386
20
    if (scan_params->__isset.broker_addresses) {
387
0
        system_properties->broker_addresses.assign(scan_params->broker_addresses.begin(),
388
0
                                                   scan_params->broker_addresses.end());
389
0
    }
390
20
    return system_properties;
391
99
}
392
393
12
std::string TableReader::debug_string() const {
394
12
    std::ostringstream out;
395
12
    out << "TableReader{format=" << file_format_to_string(_format)
396
12
        << ", push_down_agg_type=" << push_down_agg_to_string(_push_down_agg_type)
397
12
        << ", aggregate_pushdown_tried=" << _aggregate_pushdown_tried
398
12
        << ", has_current_reader=" << (_data_reader.reader != nullptr)
399
12
        << ", has_current_task=" << (_current_task != nullptr)
400
12
        << ", current_file=" << current_file_debug_string(_current_task)
401
12
        << ", has_delete_rows=" << (_delete_rows != nullptr)
402
12
        << ", delete_row_count=" << (_delete_rows == nullptr ? 0 : _delete_rows->size())
403
12
        << ", has_deletion_vector=" << (_deletion_vector != nullptr)
404
12
        << ", deletion_vector_cardinality="
405
12
        << (_deletion_vector == nullptr ? 0 : _deletion_vector->cardinality())
406
12
        << ", has_system_properties=" << (_system_properties != nullptr) << ", system_type="
407
12
        << (_system_properties == nullptr ? static_cast<int>(TFileType::FILE_LOCAL)
408
12
                                          : static_cast<int>(_system_properties->system_type))
409
12
        << ", has_scan_params=" << (_scan_params != nullptr)
410
12
        << ", has_io_ctx=" << (_io_ctx != nullptr)
411
12
        << ", has_runtime_state=" << (_runtime_state != nullptr)
412
12
        << ", has_scanner_profile=" << (_scanner_profile != nullptr)
413
12
        << ", mapper_options=" << _mapper_options.debug_string() << ", projected_columns="
414
12
        << join_table_reader_debug_strings(
415
12
                   _projected_columns,
416
12
                   [](const ColumnDefinition& column) { return column.debug_string(); })
417
12
        << ", partition_values=" << partition_values_debug_string(_partition_values)
418
12
        << ", table_filters="
419
12
        << join_table_reader_debug_strings(
420
12
                   _table_filters,
421
12
                   [](const TableFilter& filter) { return table_filter_debug_string(filter); })
422
12
        << ", conjunct_count=" << _conjuncts.size() << ", conjuncts="
423
12
        << join_table_reader_debug_strings(_conjuncts,
424
12
                                           [](const VExprContextSPtr& conjunct) {
425
1
                                               return expr_context_debug_string(conjunct);
426
1
                                           })
427
12
        << ", file_schema="
428
12
        << join_table_reader_debug_strings(
429
12
                   _data_reader.file_schema,
430
12
                   [](const ColumnDefinition& field) { return field.debug_string(); })
431
12
        << ", file_block_layout="
432
12
        << join_table_reader_debug_strings(
433
12
                   _data_reader.file_block_layout,
434
12
                   [](const FileBlockColumn& column) {
435
2
                       std::ostringstream column_out;
436
2
                       column_out << "FileBlockColumn{file_column_id=" << column.file_column_id
437
2
                                  << ", name=" << column.name << ", type="
438
2
                                  << (column.type == nullptr ? "null" : column.type->get_name())
439
2
                                  << "}";
440
2
                       return column_out.str();
441
2
                   })
442
12
        << ", block_template_columns=" << _data_reader.block_template.columns()
443
12
        << ", column_mapper="
444
12
        << (_data_reader.column_mapper == nullptr ? "null"
445
12
                                                  : _data_reader.column_mapper->debug_string())
446
12
        << "}";
447
12
    return out.str();
448
12
}
449
450
Status TableReader::annotate_projected_column(const TFileScanSlotInfo& slot_info,
451
                                              ProjectedColumnBuildContext* context,
452
8
                                              ColumnDefinition* column) const {
453
8
    (void)slot_info;
454
8
    DORIS_CHECK(context != nullptr);
455
8
    DORIS_CHECK(column != nullptr);
456
8
    context->schema_column.reset();
457
8
    const auto* schema_field = find_external_root_field(context->scan_params, *column);
458
8
    if (schema_field == nullptr) {
459
7
        return Status::OK();
460
7
    }
461
1
    context->schema_column = build_schema_column_from_external_field(*schema_field, column->type);
462
1
    column->identifier = context->schema_column->identifier;
463
1
    column->name_mapping = context->schema_column->name_mapping;
464
1
    return Status::OK();
465
8
}
466
467
99
Status TableReader::init(TableReadOptions&& options) {
468
99
    _scan_params = options.scan_params;
469
99
    _format = options.format;
470
99
    _io_ctx = options.io_ctx;
471
99
    _runtime_state = options.runtime_state;
472
99
    _scanner_profile = options.scanner_profile;
473
99
    _file_slot_descs = options.file_slot_descs;
474
99
    _push_down_agg_type = options.push_down_agg_type;
475
99
    _condition_cache_digest = options.condition_cache_digest;
476
99
    _projected_columns = std::move(options.projected_columns);
477
99
    _system_properties = create_system_properties(_scan_params);
478
99
    _mapper_options.mode = TableColumnMappingMode::BY_NAME;
479
99
    _conjuncts = std::move(options.conjuncts);
480
481
99
    if (_scanner_profile != nullptr) {
482
26
        static const char* table_profile = "TableReader";
483
26
        ADD_TIMER_WITH_LEVEL(_scanner_profile, table_profile, 1);
484
26
        _profile.num_delete_files = ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "NumDeleteFiles",
485
26
                                                                 TUnit::UNIT, table_profile, 1);
486
26
        _profile.num_delete_rows = ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "NumDeleteRows",
487
26
                                                                TUnit::UNIT, table_profile, 1);
488
26
        _profile.parse_delete_file_time = ADD_CHILD_TIMER_WITH_LEVEL(
489
26
                _scanner_profile, "ParseDeleteFileTime", table_profile, 1);
490
26
        _profile.decoded_dv_cache_hit_count =
491
26
                ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "DeletionVectorDecodedCacheHitCount",
492
26
                                             TUnit::UNIT, table_profile, 1);
493
26
        _profile.decoded_dv_cache_miss_count = ADD_CHILD_COUNTER_WITH_LEVEL(
494
26
                _scanner_profile, "DeletionVectorDecodedCacheMissCount", TUnit::UNIT, table_profile,
495
26
                1);
496
26
        _profile.dv_file_cache_hit_count = ADD_CHILD_COUNTER_WITH_LEVEL(
497
26
                _scanner_profile, "DeletionVectorFileCacheHitCount", TUnit::UNIT, table_profile, 1);
498
26
        _profile.dv_file_cache_miss_count =
499
26
                ADD_CHILD_COUNTER_WITH_LEVEL(_scanner_profile, "DeletionVectorFileCacheMissCount",
500
26
                                             TUnit::UNIT, table_profile, 1);
501
26
        _profile.dv_file_cache_peer_read_count = ADD_CHILD_COUNTER_WITH_LEVEL(
502
26
                _scanner_profile, "DeletionVectorFileCachePeerReadCount", TUnit::UNIT,
503
26
                table_profile, 1);
504
26
        _profile.exec_timer =
505
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "GetBlockTime", table_profile, 1);
506
26
        _profile.prepare_split_timer =
507
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "PrepareSplitTime", table_profile, 1);
508
26
        _profile.finalize_timer =
509
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "FinalizeBlockTime", table_profile, 1);
510
26
        _profile.create_reader_timer =
511
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "CreateReaderTime", table_profile, 1);
512
26
        _profile.pushdown_agg_timer =
513
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "PushDownAggTime", table_profile, 1);
514
26
        _profile.open_reader_timer =
515
26
                ADD_CHILD_TIMER_WITH_LEVEL(_scanner_profile, "OpenReaderTime", table_profile, 1);
516
26
        _profile.runtime_filter_partition_prune_timer = ADD_TIMER_WITH_LEVEL(
517
26
                _scanner_profile, "FileScannerRuntimeFilterPartitionPruningTime", 1);
518
26
        _profile.runtime_filter_partition_pruned_range_counter = ADD_COUNTER_WITH_LEVEL(
519
26
                _scanner_profile, "RuntimeFilterPartitionPrunedRangeNum", TUnit::UNIT, 1);
520
26
    }
521
99
    return Status::OK();
522
99
}
523
524
69
Status TableReader::_build_table_filters_from_conjuncts() {
525
69
    _table_filters.clear();
526
69
    for (const auto& conjunct : _conjuncts) {
527
25
        RETURN_IF_ERROR(
528
25
                build_table_filters_from_conjunct(conjunct, _runtime_state, &_table_filters));
529
25
    }
530
69
    return Status::OK();
531
69
}
532
533
68
Status TableReader::_open_local_filter_exprs(const FileScanRequest& file_request) {
534
68
    RowDescriptor row_desc;
535
68
    for (const auto& conjunct : file_request.conjuncts) {
536
20
        RETURN_IF_ERROR(conjunct->prepare(_runtime_state, row_desc));
537
20
        RETURN_IF_ERROR(conjunct->open(_runtime_state));
538
20
    }
539
68
    for (const auto& delete_conjunct : file_request.delete_conjuncts) {
540
13
        RETURN_IF_ERROR(delete_conjunct->prepare(_runtime_state, row_desc));
541
13
        RETURN_IF_ERROR(delete_conjunct->open(_runtime_state));
542
13
    }
543
68
    return Status::OK();
544
68
}
545
546
68
bool TableReader::_should_enable_condition_cache(const FileScanRequest& file_request) const {
547
68
    if (_condition_cache_digest == 0 || _push_down_agg_type == TPushAggOp::type::COUNT ||
548
68
        _current_file_description == std::nullopt || _data_reader.reader == nullptr) {
549
63
        return false;
550
63
    }
551
    // Condition cache is populated by file readers after evaluating file-local row-level
552
    // conjuncts. Metadata pruning can skip row groups/pages, but it does not produce a per-row
553
    // survivor bitmap that can safely populate the cache.
554
5
    if (file_request.conjuncts.empty()) {
555
1
        return false;
556
1
    }
557
    // Delete files/deletion vectors are table-format state. They may change independently of the
558
    // data file path/mtime/size used by the external cache key, so caching their result can become
559
    // stale. Keep delete filtering enabled, but do not read or write condition cache.
560
4
    if (_delete_rows != nullptr || _deletion_vector != nullptr ||
561
4
        !file_request.delete_conjuncts.empty()) {
562
1
        return false;
563
1
    }
564
    // Runtime filters can arrive late and their payload is not guaranteed to be represented by the
565
    // scan-local digest. Without a read-only mode, a MISS could insert a bitmap for P AND RF under
566
    // the digest for only P. This mirrors the old FileScanner guard.
567
3
    return !contains_runtime_filter(file_request.conjuncts);
568
4
}
569
570
68
Status TableReader::_init_reader_condition_cache(const FileScanRequest& file_request) {
571
68
    _condition_cache = nullptr;
572
68
    _condition_cache_ctx = nullptr;
573
68
    if (!_should_enable_condition_cache(file_request)) {
574
66
        return Status::OK();
575
66
    }
576
577
2
    auto* cache = segment_v2::ConditionCache::instance();
578
2
    if (cache == nullptr) {
579
0
        return Status::OK();
580
0
    }
581
2
    const auto& file = *_current_file_description;
582
2
    _condition_cache_key = segment_v2::ConditionCache::ExternalCacheKey(
583
2
            file.path, file.mtime, file.file_size, _condition_cache_digest, file.range_start_offset,
584
2
            file.range_size);
585
586
2
    segment_v2::ConditionCacheHandle handle;
587
2
    const bool condition_cache_hit = cache->lookup(_condition_cache_key, &handle);
588
2
    if (condition_cache_hit) {
589
0
        _condition_cache = handle.get_filter_result();
590
0
        ++_condition_cache_hit_count;
591
2
    } else {
592
2
        const int64_t total_rows = _data_reader.reader->get_total_rows();
593
2
        if (total_rows <= 0) {
594
0
            return Status::OK();
595
0
        }
596
        // Add one guard granule for split ranges that start in the middle of a granule. A guard
597
        // false bit beyond the real range never overlaps real rows, but avoids boundary overflow
598
        // when a reader marks the last partial granule.
599
2
        const size_t num_granules = (total_rows + ConditionCacheContext::GRANULE_SIZE - 1) /
600
2
                                    ConditionCacheContext::GRANULE_SIZE;
601
2
        _condition_cache = std::make_shared<std::vector<bool>>(num_granules + 1, false);
602
2
    }
603
604
2
    if (_condition_cache != nullptr) {
605
2
        _condition_cache_ctx = std::make_shared<ConditionCacheContext>();
606
2
        _condition_cache_ctx->is_hit = condition_cache_hit;
607
2
        _condition_cache_ctx->filter_result = _condition_cache;
608
2
        _data_reader.reader->set_condition_cache_context(_condition_cache_ctx);
609
2
    }
610
2
    return Status::OK();
611
2
}
612
613
69
void TableReader::_finalize_reader_condition_cache() {
614
69
    if (_condition_cache_ctx == nullptr || _condition_cache_ctx->is_hit) {
615
67
        _condition_cache = nullptr;
616
67
        _condition_cache_ctx = nullptr;
617
67
        return;
618
67
    }
619
    // LIMIT or scanner cancellation may close a reader before all selected row ranges are visited.
620
    // Unvisited granules remain false in a MISS bitmap, so inserting a partial bitmap would make a
621
    // later HIT skip valid rows. Only publish cache entries after the physical reader reaches EOF.
622
2
    if (!_current_reader_reached_eof) {
623
1
        _condition_cache = nullptr;
624
1
        _condition_cache_ctx = nullptr;
625
1
        return;
626
1
    }
627
1
    segment_v2::ConditionCache::instance()->insert(_condition_cache_key,
628
1
                                                   std::move(_condition_cache));
629
1
    _condition_cache = nullptr;
630
1
    _condition_cache_ctx = nullptr;
631
1
}
632
633
82
Status TableReader::create_next_reader(bool* eos) {
634
82
    SCOPED_TIMER(_profile.create_reader_timer);
635
82
    DCHECK(_data_reader.reader == nullptr);
636
82
    if (_current_task == nullptr) {
637
12
        *eos = true;
638
12
        return Status::OK();
639
12
    }
640
641
70
    RETURN_IF_ERROR(create_file_reader(&_data_reader.reader));
642
70
    DORIS_CHECK(_data_reader.reader != nullptr);
643
70
    if (_batch_size > 0) {
644
0
        _data_reader.reader->set_batch_size(_batch_size);
645
0
    }
646
70
    Status st = _data_reader.reader->init(_runtime_state);
647
70
    if (!st.ok()) {
648
1
        if (_io_ctx != nullptr && _io_ctx->should_stop && st.is<ErrorCode::END_OF_FILE>()) {
649
0
            *eos = true;
650
0
            _data_reader.reader.reset();
651
0
            return Status::OK();
652
0
        }
653
1
        return st;
654
1
    }
655
69
    st = open_reader();
656
69
    if (!st.ok()) {
657
0
        if (_io_ctx != nullptr && _io_ctx->should_stop && st.is<ErrorCode::END_OF_FILE>()) {
658
0
            *eos = true;
659
0
            _data_reader.reader.reset();
660
0
            return Status::OK();
661
0
        }
662
0
        return st;
663
0
    }
664
69
    if (_data_reader.reader == nullptr) {
665
1
        *eos = _current_task == nullptr;
666
1
        return Status::OK();
667
1
    }
668
68
    *eos = false;
669
68
    return Status::OK();
670
69
}
671
672
58
Status TableReader::create_file_reader(std::unique_ptr<FileReader>* reader) {
673
58
    DORIS_CHECK(reader != nullptr);
674
58
    const bool enable_mapping_timestamp_tz = _scan_params != nullptr &&
675
58
                                             _scan_params->__isset.enable_mapping_timestamp_tz &&
676
58
                                             _scan_params->enable_mapping_timestamp_tz;
677
58
    if (_format == FileFormat::PARQUET) {
678
58
        *reader = std::make_unique<format::parquet::ParquetReader>(
679
58
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile,
680
58
                _global_rowid_context, enable_mapping_timestamp_tz);
681
58
        return Status::OK();
682
58
    }
683
0
    if (_format == FileFormat::ORC) {
684
0
        *reader = std::make_unique<format::orc::OrcReader>(
685
0
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile,
686
0
                _global_rowid_context, enable_mapping_timestamp_tz);
687
0
        return Status::OK();
688
0
    }
689
0
    if (_format == FileFormat::CSV) {
690
0
        if (_file_slot_descs == nullptr) {
691
0
            return Status::InvalidArgument("CSV reader requires file slot descriptors");
692
0
        }
693
        // CSV has no embedded schema. TableReader owns table-level mapping, while CsvReader needs
694
        // only the physical file slots plus scan text parameters to build a file-local schema.
695
        // Non-file columns such as partitions/defaults/virtual row ids are intentionally excluded
696
        // from `_file_slot_descs` and are materialized during finalize_chunk().
697
0
        *reader = std::make_unique<format::csv::CsvReader>(
698
0
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile,
699
0
                _scan_params, *_file_slot_descs, _current_range_compress_type,
700
0
                _current_range_load_id);
701
0
        return Status::OK();
702
0
    }
703
0
    if (_format == FileFormat::TEXT) {
704
0
        if (_file_slot_descs == nullptr) {
705
0
            return Status::InvalidArgument("Text reader requires file slot descriptors");
706
0
        }
707
        // Text files have no embedded schema. As with CSV, TableReader handles table-level mapping
708
        // and only passes physical file slots to the v2 TextReader.
709
0
        *reader = std::make_unique<format::text::TextReader>(
710
0
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile,
711
0
                _scan_params, *_file_slot_descs, _current_range_compress_type,
712
0
                _current_range_load_id);
713
0
        return Status::OK();
714
0
    }
715
0
    if (_format == FileFormat::JSON) {
716
0
        if (_file_slot_descs == nullptr) {
717
0
            return Status::InvalidArgument("JSON reader requires file slot descriptors");
718
0
        }
719
0
        *reader = std::make_unique<format::json::JsonReader>(
720
0
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile,
721
0
                _scan_params, _current_file_range_desc, *_file_slot_descs,
722
0
                _current_range_compress_type, _current_range_load_id);
723
0
        return Status::OK();
724
0
    }
725
0
    if (_format == FileFormat::NATIVE) {
726
0
        *reader = std::make_unique<format::native::NativeReader>(
727
0
                _system_properties, _current_task->data_file, _io_ctx, _scanner_profile);
728
0
        return Status::OK();
729
0
    }
730
0
    return Status::NotSupported("TableReader does not support file format {}",
731
0
                                file_format_to_string(_format));
732
0
}
733
734
89
std::unique_ptr<io::FileDescription> create_file_description(const TFileRangeDesc& range) {
735
89
    auto file_description = std::make_unique<io::FileDescription>();
736
89
    file_description->path = range.path;
737
89
    file_description->file_size = range.__isset.file_size ? range.file_size : -1;
738
89
    file_description->mtime = range.__isset.modification_time ? range.modification_time : 0;
739
89
    file_description->range_start_offset = range.__isset.start_offset ? range.start_offset : 0;
740
89
    file_description->range_size = range.__isset.size ? range.size : -1;
741
89
    if (range.__isset.fs_name) {
742
1
        file_description->fs_name = range.fs_name;
743
1
    }
744
89
    if (range.__isset.file_cache_admission) {
745
0
        file_description->file_cache_admission = range.file_cache_admission;
746
0
    }
747
89
    return file_description;
748
89
}
749
750
90
Status TableReader::prepare_split(const SplitReadOptions& options) {
751
90
    SCOPED_TIMER(_profile.prepare_split_timer);
752
90
    _current_split_pruned = false;
753
    // Update to current split format to handle ORC/PARQUET files in one table.
754
90
    _format = options.current_split_format;
755
90
    _partition_values = std::move(options.partition_values);
756
90
    _current_task.reset();
757
90
    _current_file_description.reset();
758
90
    _current_file_range_desc = options.current_range;
759
90
    _current_range_compress_type = options.current_range.__isset.compress_type
760
90
                                           ? options.current_range.compress_type
761
90
                                           : TFileCompressType::UNKNOWN;
762
90
    _current_range_load_id = options.current_range.__isset.load_id
763
90
                                     ? std::make_optional(options.current_range.load_id)
764
90
                                     : std::nullopt;
765
90
    _global_rowid_context = options.global_rowid_context;
766
90
    _delete_rows = nullptr;
767
90
    _deletion_vector = nullptr;
768
90
    _aggregate_pushdown_tried = false;
769
90
    _remaining_table_level_count = -1;
770
90
    _current_reader_reached_eof = false;
771
90
    RETURN_IF_ERROR(_evaluate_partition_prune_conjuncts(options.partition_prune_conjuncts,
772
90
                                                        &_current_split_pruned));
773
90
    if (_current_split_pruned) {
774
1
        COUNTER_UPDATE(_profile.runtime_filter_partition_pruned_range_counter, 1);
775
1
        return Status::OK();
776
1
    }
777
89
    _current_task = std::make_unique<ScanTask>();
778
89
    _current_task->data_file = create_file_description(options.current_range);
779
89
    _current_file_description = *_current_task->data_file;
780
89
    if (_push_down_agg_type == TPushAggOp::type::COUNT &&
781
89
        options.current_range.__isset.table_format_params &&
782
89
        options.current_range.table_format_params.__isset.table_level_row_count) {
783
6
        DORIS_CHECK(options.current_range.table_format_params.table_level_row_count >= -1);
784
6
        _remaining_table_level_count =
785
6
                options.current_range.table_format_params.table_level_row_count;
786
6
    }
787
89
    if (_is_table_level_count_active()) {
788
2
        return Status::OK();
789
2
    }
790
87
    return _parse_delete_predicates(options);
791
89
}
792
793
Status TableReader::_evaluate_partition_prune_conjuncts(const VExprContextSPtrs& conjuncts,
794
90
                                                        bool* can_filter_all) {
795
90
    DORIS_CHECK(can_filter_all != nullptr);
796
90
    SCOPED_TIMER(_profile.runtime_filter_partition_prune_timer);
797
90
    *can_filter_all = false;
798
90
    if (conjuncts.empty() || _partition_values.empty()) {
799
88
        return Status::OK();
800
88
    }
801
802
2
    VExprContextSPtrs partition_conjuncts;
803
2
    for (const auto& conjunct : conjuncts) {
804
2
        DORIS_CHECK(conjunct != nullptr);
805
2
        DORIS_CHECK(conjunct->root() != nullptr);
806
2
        std::set<GlobalIndex> global_indices;
807
2
        collect_global_indices(conjunct->root(), &global_indices);
808
2
        if (global_indices.empty()) {
809
0
            continue;
810
0
        }
811
2
        const bool partition_only = std::ranges::all_of(global_indices, [&](GlobalIndex index) {
812
2
            if (index.value() >= _projected_columns.size()) {
813
0
                return false;
814
0
            }
815
2
            const auto& column = _projected_columns[index.value()];
816
2
            return column.is_partition_key &&
817
2
                   find_partition_value(column, _partition_values) != nullptr;
818
2
        });
819
2
        if (partition_only) {
820
2
            partition_conjuncts.push_back(conjunct);
821
2
        }
822
2
    }
823
2
    if (partition_conjuncts.empty()) {
824
0
        return Status::OK();
825
0
    }
826
827
2
    Block block;
828
2
    RETURN_IF_ERROR(_build_partition_prune_block(&block));
829
2
    RowDescriptor row_desc;
830
2
    for (const auto& conjunct : partition_conjuncts) {
831
2
        RETURN_IF_ERROR(conjunct->prepare(_runtime_state, row_desc));
832
2
        RETURN_IF_ERROR(conjunct->open(_runtime_state));
833
2
    }
834
2
    IColumn::Filter result_filter(block.rows(), 1);
835
2
    return VExprContext::execute_conjuncts(partition_conjuncts, nullptr, &block, &result_filter,
836
2
                                           can_filter_all);
837
2
}
838
839
2
Status TableReader::_build_partition_prune_block(Block* block) const {
840
2
    DORIS_CHECK(block != nullptr);
841
2
    DORIS_CHECK(!_projected_columns.empty());
842
2
    block->clear();
843
2
    for (const auto& column : _projected_columns) {
844
2
        DORIS_CHECK(column.type != nullptr);
845
2
        ColumnPtr value_column = column.type->create_column_const_with_default_value(1);
846
2
        if (column.is_partition_key) {
847
2
            const auto* partition_value = find_partition_value(column, _partition_values);
848
2
            if (partition_value != nullptr) {
849
2
                value_column = column.type->create_column_const(1, *partition_value);
850
2
            }
851
2
        }
852
2
        block->insert({std::move(value_column), column.type, column.name});
853
2
    }
854
2
    return Status::OK();
855
2
}
856
857
87
Status TableReader::_parse_delete_predicates(const SplitReadOptions& options) {
858
87
    DeleteFileDesc desc {.fs_name = options.current_range.fs_name};
859
87
    bool has_delete_file = false;
860
87
    RETURN_IF_ERROR(_parse_deletion_vector_file(options.current_range.table_format_params, &desc,
861
87
                                                &has_delete_file));
862
87
    if (has_delete_file) {
863
7
        DORIS_CHECK(options.cache != nullptr);
864
7
        Status create_status = Status::OK();
865
866
7
        bool decoded_cache_hit = false;
867
7
        _deletion_vector = options.cache->get<DeletionVector>(
868
7
                desc.key,
869
7
                [&]() -> DeletionVector* {
870
7
                    auto deletion_vector = std::make_unique<DeletionVector>();
871
872
7
                    DeletionVectorReader dv_reader(_runtime_state, _scanner_profile, *_scan_params,
873
7
                                                   desc, _io_ctx.get());
874
7
                    create_status = dv_reader.open();
875
7
                    if (!create_status.ok()) [[unlikely]] {
876
0
                        return nullptr;
877
0
                    }
878
879
7
                    size_t bytes_read = desc.size;
880
7
                    std::vector<char> buffer(bytes_read);
881
7
                    DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.io_error", {
882
7
                        create_status =
883
7
                                Status::IOError("injected format v2 deletion vector read failure");
884
7
                        return nullptr;
885
7
                    });
886
6
                    DBUG_EXECUTE_IF("TableReader.parse_deletion_vector.should_stop", {
887
6
                        create_status = Status::EndOfFile("stop read.");
888
6
                        return nullptr;
889
6
                    });
890
5
                    create_status =
891
5
                            dv_reader.read_at(desc.start_offset, {buffer.data(), bytes_read});
892
5
                    const auto& file_cache_stats = dv_reader.file_cache_statistics();
893
5
                    COUNTER_UPDATE(_profile.dv_file_cache_hit_count,
894
5
                                   file_cache_stats.num_local_io_total);
895
5
                    COUNTER_UPDATE(_profile.dv_file_cache_miss_count,
896
5
                                   file_cache_stats.num_remote_io_total);
897
5
                    COUNTER_UPDATE(_profile.dv_file_cache_peer_read_count,
898
5
                                   file_cache_stats.num_peer_io_total);
899
5
                    if (!create_status.ok()) [[unlikely]] {
900
0
                        return nullptr;
901
0
                    }
902
903
5
                    const char* buf = buffer.data();
904
5
                    SCOPED_TIMER(_profile.parse_delete_file_time);
905
5
                    create_status = parse_deletion_vector(buf, bytes_read, desc.format,
906
5
                                                          deletion_vector.get());
907
5
                    if (!create_status.ok()) [[unlikely]] {
908
1
                        return nullptr;
909
1
                    }
910
4
                    COUNTER_UPDATE(_profile.num_delete_rows, deletion_vector->cardinality());
911
4
                    return deletion_vector.release();
912
5
                },
913
7
                &decoded_cache_hit);
914
7
        RETURN_IF_ERROR(create_status);
915
4
        COUNTER_UPDATE(decoded_cache_hit ? _profile.decoded_dv_cache_hit_count
916
4
                                         : _profile.decoded_dv_cache_miss_count,
917
4
                       1);
918
4
    }
919
920
84
    return Status::OK();
921
87
}
922
} // namespace doris::format