Coverage Report

Created: 2026-03-12 17:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/table/iceberg/schema.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/iceberg/schema.h"
19
20
namespace doris::iceberg {
21
#include "common/compile_check_begin.h"
22
23
const std::string Schema::ALL_COLUMNS = "*";
24
const int Schema::DEFAULT_SCHEMA_ID = 0;
25
26
Schema::Schema(int schema_id, std::vector<NestedField> columns)
27
3.23k
        : _schema_id(schema_id), _root_struct(std::move(columns)) {
28
3.23k
    _id_to_field.reserve(_root_struct.fields().size());
29
39.3k
    for (const auto& field : _root_struct.fields()) {
30
39.3k
        int field_id = field.field_id();
31
39.3k
        _id_to_field[field_id] = &field;
32
39.3k
    }
33
3.23k
}
34
3.22k
Schema::Schema(std::vector<NestedField> columns) : Schema(DEFAULT_SCHEMA_ID, std::move(columns)) {}
35
36
2
Type* Schema::find_type(int id) const {
37
2
    auto it = _id_to_field.find(id);
38
2
    if (it != _id_to_field.end()) {
39
2
        return it->second->field_type();
40
2
    }
41
0
    return nullptr;
42
2
}
43
44
6
const NestedField* Schema::find_field(int id) const {
45
6
    auto it = _id_to_field.find(id);
46
6
    if (it != _id_to_field.end()) {
47
6
        return it->second;
48
6
    }
49
0
    return nullptr;
50
6
}
51
52
#include "common/compile_check_end.h"
53
} // namespace doris::iceberg