Coverage Report

Created: 2026-07-23 18:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exec/scan/access_path_parser.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 "exec/scan/access_path_parser.h"
19
20
#include <fmt/format.h>
21
22
#include <algorithm>
23
#include <charconv>
24
#include <map>
25
#include <string>
26
#include <string_view>
27
#include <utility>
28
29
#include "common/cast_set.h"
30
#include "common/consts.h"
31
#include "core/assert_cast.h"
32
#include "core/data_type/data_type.h"
33
#include "core/data_type/data_type_array.h"
34
#include "core/data_type/data_type_map.h"
35
#include "core/data_type/data_type_nullable.h"
36
#include "core/data_type/data_type_struct.h"
37
#include "runtime/descriptors.h"
38
#include "util/string_util.h"
39
40
namespace doris {
41
namespace {
42
43
239k
bool is_scanner_materialized_virtual_column(const std::string& column_name) {
44
239k
    return column_name == BeConsts::ICEBERG_ROWID_COL;
45
239k
}
46
47
40.4k
bool parse_non_negative_int(std::string_view value, int32_t* result) {
48
40.4k
    DORIS_CHECK(result != nullptr);
49
40.4k
    int32_t parsed = -1;
50
40.4k
    const auto* begin = value.data();
51
40.4k
    const auto* end = begin + value.size();
52
40.4k
    const auto [ptr, ec] = std::from_chars(begin, end, parsed);
53
40.4k
    if (ec != std::errc() || ptr != end || parsed < 0) {
54
16.4k
        return false;
55
16.4k
    }
56
23.9k
    *result = parsed;
57
23.9k
    return true;
58
40.4k
}
59
60
2
std::string access_path_to_string(const std::vector<std::string>& path) {
61
2
    return fmt::format("{}", fmt::join(path, "."));
62
2
}
63
64
format::ColumnDefinition* find_or_add_child(format::ColumnDefinition* parent, int32_t id,
65
162k
                                            std::string name, DataTypePtr type) {
66
162k
    DORIS_CHECK(parent != nullptr);
67
162k
    for (auto& child : parent->children) {
68
70.1k
        if ((child.has_identifier_field_id() && child.get_identifier_field_id() == id) ||
69
70.1k
            child.name == name) {
70
0
            return &child;
71
0
        }
72
70.1k
    }
73
162k
    parent->children.push_back({
74
162k
            .identifier = Field::create_field<TYPE_INT>(id),
75
162k
            .name = std::move(name),
76
162k
            .type = std::move(type),
77
162k
            .children = {},
78
162k
            .default_expr = nullptr,
79
162k
            .is_partition_key = false,
80
162k
    });
81
162k
    return &parent->children.back();
82
162k
}
83
84
void inherit_schema_metadata(format::ColumnDefinition* column,
85
162k
                             const format::ColumnDefinition* schema_column) {
86
162k
    if (column == nullptr || schema_column == nullptr) {
87
118k
        return;
88
118k
    }
89
44.1k
    column->name_mapping = schema_column->name_mapping;
90
    // The presence bit is part of the mapping contract: an explicit empty mapping must remain
91
    // authoritative after access-path pruning instead of enabling current-name fallback.
92
44.1k
    column->has_name_mapping = schema_column->has_name_mapping;
93
    // Initial defaults describe the logical value of fields absent from older files. Nested
94
    // access-path pruning must retain them just like it retains rename metadata.
95
44.1k
    column->initial_default_value = schema_column->initial_default_value;
96
44.1k
    column->initial_default_value_is_base64 = schema_column->initial_default_value_is_base64;
97
44.1k
}
98
99
const format::ColumnDefinition* find_schema_child_by_path(
100
        const format::ColumnDefinition* schema_column, const std::string& child_path,
101
46.5k
        bool prefer_exact_name_match) {
102
46.5k
    if (schema_column == nullptr) {
103
27.7k
        return nullptr;
104
27.7k
    }
105
18.7k
    int32_t parsed_field_id = -1;
106
18.7k
    if (parse_non_negative_int(child_path, &parsed_field_id)) {
107
2.35k
        const auto child_it = std::ranges::find_if(
108
3.33k
                schema_column->children, [&](const format::ColumnDefinition& child) {
109
3.33k
                    return child.has_identifier_field_id() &&
110
3.33k
                           child.get_identifier_field_id() == parsed_field_id;
111
3.33k
                });
112
2.35k
        return child_it == schema_column->children.end() ? nullptr : &*child_it;
113
2.35k
    }
114
16.4k
    if (!prefer_exact_name_match) {
115
1
        const auto child_it = std::ranges::find_if(schema_column->children, [&](const auto& child) {
116
1
            if (to_lower(child.name) == to_lower(child_path)) {
117
0
                return true;
118
0
            }
119
1
            return std::ranges::any_of(child.name_mapping, [&](const std::string& alias) {
120
1
                return to_lower(alias) == to_lower(child_path);
121
1
            });
122
1
        });
123
1
        return child_it == schema_column->children.end() ? nullptr : &*child_it;
124
1
    }
125
    // Iceberg can reuse a historical name for a newly added sibling. Current names therefore
126
    // have precedence across the entire struct; an earlier alias must not steal that access path.
127
28.8k
    const auto exact_it = std::ranges::find_if(schema_column->children, [&](const auto& child) {
128
28.8k
        return to_lower(child.name) == to_lower(child_path);
129
28.8k
    });
130
16.4k
    if (exact_it != schema_column->children.end()) {
131
16.4k
        return &*exact_it;
132
16.4k
    }
133
18.4E
    const auto alias_it = std::ranges::find_if(schema_column->children, [&](const auto& child) {
134
11
        return std::ranges::any_of(child.name_mapping, [&](const std::string& alias) {
135
6
            return to_lower(alias) == to_lower(child_path);
136
6
        });
137
11
    });
138
18.4E
    return alias_it == schema_column->children.end() ? nullptr : &*alias_it;
139
16.4k
}
140
141
162k
int32_t schema_field_id(const format::ColumnDefinition* schema_column) {
142
162k
    if (schema_column == nullptr || !schema_column->has_identifier_field_id()) {
143
118k
        return -1;
144
118k
    }
145
44.1k
    return schema_column->get_identifier_field_id();
146
162k
}
147
148
160k
int32_t schema_field_id_or(const format::ColumnDefinition* schema_column, int32_t fallback) {
149
160k
    const auto field_id = schema_field_id(schema_column);
150
160k
    return field_id >= 0 ? field_id : fallback;
151
160k
}
152
153
std::string schema_field_name_or(const format::ColumnDefinition* schema_column,
154
44.0k
                                 std::string fallback) {
155
44.0k
    return schema_column == nullptr || schema_column->name.empty() ? std::move(fallback)
156
44.0k
                                                                   : schema_column->name;
157
44.0k
}
158
159
struct AccessPathNode {
160
    bool project_all = false;
161
    std::map<std::string, AccessPathNode> children;
162
};
163
164
1.21k
void merge_access_path_node(AccessPathNode* dst, const AccessPathNode& src) {
165
1.21k
    DORIS_CHECK(dst != nullptr);
166
1.21k
    if (dst->project_all) {
167
0
        return;
168
0
    }
169
1.21k
    if (src.project_all) {
170
771
        dst->project_all = true;
171
771
        dst->children.clear();
172
771
        return;
173
771
    }
174
578
    for (const auto& [path, child] : src.children) {
175
578
        merge_access_path_node(&dst->children[path], child);
176
578
    }
177
448
}
178
179
void insert_access_path(AccessPathNode* root, const std::vector<std::string>& path,
180
48.5k
                        size_t path_idx) {
181
48.5k
    DORIS_CHECK(root != nullptr);
182
48.5k
    if (root->project_all) {
183
0
        return;
184
0
    }
185
48.5k
    if (path_idx >= path.size()) {
186
44.7k
        root->project_all = true;
187
44.7k
        root->children.clear();
188
44.7k
        return;
189
44.7k
    }
190
3.72k
    insert_access_path(&root->children[path[path_idx]], path, path_idx + 1);
191
3.72k
}
192
193
Status build_nested_children_from_access_node(format::ColumnDefinition* column,
194
                                              const DataTypePtr& type, const AccessPathNode& node,
195
                                              const std::string& path,
196
                                              const format::ColumnDefinition* schema_column,
197
                                              bool prefer_exact_name_match);
198
199
// Expand a full complex-column projection into table-schema children when the table format provides
200
// an external/current schema. Without this, `SELECT complex_col` or `SELECT *` leaves
201
// ColumnDefinition::children empty, so ColumnMapper treats the root complex column as a scalar
202
// mapping and later tries to cast the old file shape to the current table shape directly.
203
//
204
// Examples:
205
//   - STRUCT country/city projected from an old file STRUCT country/population/location should
206
//     create children country and city, so city can be materialized as missing/default.
207
//   - ARRAY<STRUCT<item, quantity>> should create the array element wrapper and then the element
208
//     struct children item and quantity.
209
//   - MAP<STRING, STRUCT<full_name, age>> should create semantic children key/value directly, then
210
//     expand the value struct children full_name and age. Do not introduce a physical entries
211
//     wrapper here: ColumnMapper and TableReader treat MAP children as [key, value].
212
Status build_all_nested_children_from_schema(format::ColumnDefinition* column,
213
                                             const DataTypePtr& type, const std::string& path,
214
                                             const format::ColumnDefinition* schema_column,
215
248k
                                             bool prefer_exact_name_match) {
216
248k
    DORIS_CHECK(column != nullptr);
217
218
248k
    const auto nested_type = remove_nullable(type);
219
248k
    AccessPathNode project_all;
220
248k
    project_all.project_all = true;
221
248k
    switch (nested_type->get_primitive_type()) {
222
21.5k
    case TYPE_STRUCT: {
223
21.5k
        const auto& struct_type = assert_cast<const DataTypeStruct&>(*nested_type);
224
65.6k
        for (size_t field_idx = 0; field_idx < struct_type.get_elements().size(); ++field_idx) {
225
44.0k
            const auto field_name = struct_type.get_element_name(field_idx);
226
44.0k
            const auto* schema_child =
227
44.0k
                    find_schema_child_by_path(schema_column, field_name, prefer_exact_name_match);
228
44.0k
            auto* child = find_or_add_child(
229
44.0k
                    column, schema_field_id_or(schema_child, cast_set<int32_t>(field_idx)),
230
44.0k
                    schema_field_name_or(schema_child, field_name),
231
44.0k
                    struct_type.get_element(field_idx));
232
44.0k
            inherit_schema_metadata(child, schema_child);
233
44.0k
            RETURN_IF_ERROR(build_nested_children_from_access_node(
234
44.0k
                    child, child->type, project_all, path + "." + child->name, schema_child,
235
44.0k
                    prefer_exact_name_match));
236
44.0k
        }
237
21.5k
        return Status::OK();
238
21.5k
    }
239
45.3k
    case TYPE_ARRAY: {
240
45.3k
        const auto& array_type = assert_cast<const DataTypeArray&>(*nested_type);
241
45.3k
        const auto* element_schema = schema_column != nullptr && !schema_column->children.empty()
242
45.3k
                                             ? &schema_column->children[0]
243
45.3k
                                             : nullptr;
244
45.3k
        auto* child = find_or_add_child(column, schema_field_id_or(element_schema, 0), "element",
245
45.3k
                                        array_type.get_nested_type());
246
45.3k
        inherit_schema_metadata(child, element_schema);
247
45.3k
        return build_nested_children_from_access_node(child, child->type, project_all, path + ".*",
248
45.3k
                                                      element_schema, prefer_exact_name_match);
249
21.5k
    }
250
34.6k
    case TYPE_MAP: {
251
34.6k
        const auto& map_type = assert_cast<const DataTypeMap&>(*nested_type);
252
34.6k
        const auto* key_schema = schema_column != nullptr && !schema_column->children.empty()
253
34.6k
                                         ? &schema_column->children[0]
254
34.6k
                                         : nullptr;
255
34.6k
        const auto* value_schema = schema_column != nullptr && schema_column->children.size() > 1
256
34.6k
                                           ? &schema_column->children[1]
257
34.6k
                                           : nullptr;
258
34.6k
        auto* key_child = find_or_add_child(column, schema_field_id_or(key_schema, 0), "key",
259
34.6k
                                            map_type.get_key_type());
260
34.6k
        inherit_schema_metadata(key_child, key_schema);
261
34.6k
        RETURN_IF_ERROR(build_nested_children_from_access_node(
262
34.6k
                key_child, key_child->type, project_all, path + ".KEYS", key_schema,
263
34.6k
                prefer_exact_name_match));
264
34.6k
        auto* value_child = find_or_add_child(column, schema_field_id_or(value_schema, 1), "value",
265
34.6k
                                              map_type.get_value_type());
266
34.6k
        inherit_schema_metadata(value_child, value_schema);
267
34.6k
        RETURN_IF_ERROR(build_nested_children_from_access_node(
268
34.6k
                value_child, value_child->type, project_all, path + ".VALUES", value_schema,
269
34.6k
                prefer_exact_name_match));
270
34.6k
        return Status::OK();
271
34.6k
    }
272
146k
    default:
273
146k
        return Status::OK();
274
248k
    }
275
248k
}
276
277
Status build_struct_children_from_access_node(format::ColumnDefinition* column,
278
                                              const DataTypeStruct& struct_type,
279
                                              const AccessPathNode& node, const std::string& path,
280
                                              const format::ColumnDefinition* schema_column,
281
1.87k
                                              bool prefer_exact_name_match) {
282
1.87k
    DORIS_CHECK(column != nullptr);
283
2.49k
    for (const auto& [child_path, child_node] : node.children) {
284
        // Struct children are resolved by name or schema field id. We do not treat a numeric
285
        // child token as a struct ordinal, because `col.0` becomes ambiguous once the struct
286
        // evolves. Position-based access needs a separate design if it is required later.
287
2.49k
        if (child_path == "OFFSET" || child_path == "*" || child_path == "KEYS" ||
288
2.49k
            child_path == "VALUES") {
289
4
            return Status::NotSupported(
290
4
                    "AccessPathParser does not support access path {} for slot {}",
291
4
                    path + "." + child_path, column->name);
292
4
        }
293
294
        // Prefer the table/schema ColumnDefinition because it carries field ids and aliases.
295
        // Fallback to the struct type name only for formats without external schema metadata.
296
2.48k
        const auto* schema_child =
297
2.48k
                find_schema_child_by_path(schema_column, child_path, prefer_exact_name_match);
298
2.48k
        int32_t field_id = schema_field_id(schema_child);
299
2.48k
        std::string field_name = schema_child == nullptr ? child_path : schema_child->name;
300
2.48k
        DataTypePtr field_type = schema_child == nullptr ? nullptr : schema_child->type;
301
2.48k
        if (field_id < 0 || field_type == nullptr) {
302
167
            for (size_t field_idx = 0; field_idx < struct_type.get_elements().size(); ++field_idx) {
303
164
                if (to_lower(struct_type.get_element_name(field_idx)) == to_lower(field_name)) {
304
123
                    field_id = cast_set<int32_t>(field_idx);
305
123
                    field_name = struct_type.get_element_name(field_idx);
306
123
                    field_type = struct_type.get_element(field_idx);
307
123
                    break;
308
123
                }
309
164
            }
310
126
        }
311
312
2.48k
        if (field_id < 0 || field_type == nullptr) {
313
3
            return Status::NotSupported(
314
3
                    "AccessPathParser does not support access path {} for slot {}",
315
3
                    path + "." + child_path, column->name);
316
3
        }
317
        // TODO: For TVF Parquet files without field ids, this fallback uses the struct ordinal as
318
        // the table child identifier. BY_NAME mapping should instead keep a string identifier and
319
        // let TableColumnMapper resolve the file-local child id from the Parquet schema.
320
2.48k
        auto* child = find_or_add_child(column, field_id, field_name, field_type);
321
2.48k
        inherit_schema_metadata(child, schema_child);
322
2.48k
        RETURN_IF_ERROR(build_nested_children_from_access_node(
323
2.48k
                child, child->type, child_node, path + "." + child_path, schema_child,
324
2.48k
                prefer_exact_name_match));
325
2.48k
    }
326
1.86k
    return Status::OK();
327
1.87k
}
328
329
Status build_map_children_from_access_node(format::ColumnDefinition* column,
330
                                           const DataTypeMap& map_type, const AccessPathNode& node,
331
                                           const std::string& path,
332
                                           const format::ColumnDefinition* schema_column,
333
570
                                           bool prefer_exact_name_match) {
334
570
    DORIS_CHECK(column != nullptr);
335
570
    AccessPathNode key_node;
336
570
    AccessPathNode value_node;
337
570
    bool need_key = false;
338
570
    bool need_value = false;
339
340
643
    for (const auto& [child_path, child_node] : node.children) {
341
643
        if (child_path == "OFFSET") {
342
1
            return Status::NotSupported(
343
1
                    "AccessPathParser does not support access path {} for slot {}",
344
1
                    path + "." + child_path, column->name);
345
1
        }
346
642
        if (child_path == "KEYS") {
347
115
            need_key = true;
348
115
            merge_access_path_node(&key_node, child_node);
349
115
            continue;
350
115
        }
351
527
        if (child_path == "VALUES") {
352
391
            need_key = true;
353
391
            key_node.project_all = true;
354
391
            key_node.children.clear();
355
391
            need_value = true;
356
391
            merge_access_path_node(&value_node, child_node);
357
391
            continue;
358
391
        }
359
136
        if (child_path == "*") {
360
135
            need_key = true;
361
135
            key_node.project_all = true;
362
135
            key_node.children.clear();
363
135
            need_value = true;
364
135
            merge_access_path_node(&value_node, child_node);
365
135
            continue;
366
135
        }
367
1
        return Status::NotSupported("AccessPathParser does not support access path {} for slot {}",
368
1
                                    path + "." + child_path, column->name);
369
136
    }
370
568
    if (need_key && !need_value) {
371
        // A key-only MAP projection is not independently materializable yet. FileScannerV2 can
372
        // describe a projection such as `m.KEYS`, but the downstream file block -> table block path
373
        // still builds a ColumnMap from key column + value column + offsets. If the value child is
374
        // omitted here, TableReader/ColumnMapper cannot reconstruct a valid table MAP column even
375
        // though the query only needs keys.
376
        //
377
        // Example:
378
        //   SELECT map_keys(m) FROM t;
379
        // or
380
        //   SELECT * FROM t WHERE array_contains(map_keys(m), 'k1');
381
        //
382
        // The access path only asks for `m.KEYS`, but the scan still has to read `m.VALUES` as a
383
        // temporary full projection until map materialization supports constructing a table MAP
384
        // from keys only.
385
43
        need_value = true;
386
43
        value_node.project_all = true;
387
43
        value_node.children.clear();
388
43
    }
389
390
568
    if (!need_key && !need_value) {
391
0
        return Status::OK();
392
0
    }
393
394
568
    const auto* key_schema = schema_column != nullptr && !schema_column->children.empty()
395
568
                                     ? &schema_column->children[0]
396
568
                                     : nullptr;
397
568
    const auto* value_schema = schema_column != nullptr && schema_column->children.size() > 1
398
568
                                       ? &schema_column->children[1]
399
568
                                       : nullptr;
400
568
    if (need_key) {
401
568
        auto* key_child = find_or_add_child(column, schema_field_id_or(key_schema, 0), "key",
402
568
                                            map_type.get_key_type());
403
568
        inherit_schema_metadata(key_child, key_schema);
404
568
        RETURN_IF_ERROR(build_nested_children_from_access_node(key_child, key_child->type, key_node,
405
568
                                                               path + ".KEYS", key_schema,
406
568
                                                               prefer_exact_name_match));
407
568
    }
408
568
    if (need_value) {
409
568
        auto* value_child = find_or_add_child(column, schema_field_id_or(value_schema, 1), "value",
410
568
                                              map_type.get_value_type());
411
568
        inherit_schema_metadata(value_child, value_schema);
412
568
        RETURN_IF_ERROR(build_nested_children_from_access_node(
413
568
                value_child, value_child->type, value_node, path + ".VALUES", value_schema,
414
568
                prefer_exact_name_match));
415
568
    }
416
567
    return Status::OK();
417
568
}
418
419
Status build_nested_children_from_access_node(format::ColumnDefinition* column,
420
                                              const DataTypePtr& type, const AccessPathNode& node,
421
                                              const std::string& path,
422
                                              const format::ColumnDefinition* schema_column,
423
251k
                                              bool prefer_exact_name_match) {
424
251k
    DORIS_CHECK(column != nullptr);
425
251k
    if (node.project_all || node.children.empty()) {
426
248k
        return build_all_nested_children_from_schema(column, type, path, schema_column,
427
248k
                                                     prefer_exact_name_match);
428
248k
    }
429
430
2.75k
    const auto nested_type = remove_nullable(type);
431
2.75k
    switch (nested_type->get_primitive_type()) {
432
1.87k
    case TYPE_STRUCT:
433
1.87k
        return build_struct_children_from_access_node(
434
1.87k
                column, assert_cast<const DataTypeStruct&>(*nested_type), node, path, schema_column,
435
1.87k
                prefer_exact_name_match);
436
315
    case TYPE_ARRAY: {
437
315
        if (node.children.size() != 1 || !node.children.contains("*")) {
438
2
            return Status::NotSupported(
439
2
                    "AccessPathParser does not support access path {} for slot {}", path,
440
2
                    column->name);
441
2
        }
442
313
        const auto& array_type = assert_cast<const DataTypeArray&>(*nested_type);
443
313
        const auto* element_schema = schema_column != nullptr && !schema_column->children.empty()
444
313
                                             ? &schema_column->children[0]
445
313
                                             : nullptr;
446
313
        auto* child = find_or_add_child(column, schema_field_id_or(element_schema, 0), "element",
447
313
                                        array_type.get_nested_type());
448
313
        inherit_schema_metadata(child, element_schema);
449
313
        return build_nested_children_from_access_node(child, child->type, node.children.at("*"),
450
313
                                                      path + ".*", element_schema,
451
313
                                                      prefer_exact_name_match);
452
315
    }
453
570
    case TYPE_MAP:
454
570
        return build_map_children_from_access_node(
455
570
                column, assert_cast<const DataTypeMap&>(*nested_type), node, path, schema_column,
456
570
                prefer_exact_name_match);
457
0
    default:
458
0
        return Status::NotSupported("AccessPathParser does not support access path {} for slot {}",
459
0
                                    path, column->name);
460
2.75k
    }
461
2.75k
}
462
463
} // namespace
464
465
Status AccessPathParser::build_nested_children(format::ColumnDefinition* column,
466
                                               const std::vector<TColumnAccessPath>& access_paths,
467
                                               const format::ColumnDefinition* schema_column,
468
239k
                                               bool prefer_exact_name_match) {
469
239k
    DORIS_CHECK(column != nullptr);
470
239k
    if (is_scanner_materialized_virtual_column(column->name)) {
471
435
        return Status::OK();
472
435
    }
473
239k
    if (!is_complex_type(remove_nullable(column->type)->get_primitive_type())) {
474
150k
        return Status::OK();
475
150k
    }
476
477
88.4k
    AccessPathNode root;
478
    // Build tree for AccessPathNode.
479
    // For example, for access paths ["a.b", "a.c", "d"], the tree will be:
480
    // root
481
    // ├── a
482
    // │   ├── b
483
    // │   └── c
484
    // └── d
485
88.4k
    for (const auto& access_path : access_paths) {
486
        // TODO: Support META access paths if needed. Currently AccessPathParser only supports
487
        // DATA access paths.
488
44.7k
        if (access_path.type != TAccessPathType::DATA || !access_path.__isset.data_access_path) {
489
2
            return Status::NotSupported(
490
2
                    "AccessPathParser only supports DATA access paths for slot {}", column->name);
491
2
        }
492
44.7k
        const auto& path = access_path.data_access_path.path;
493
44.7k
        if (path.empty()) {
494
0
            insert_access_path(&root, path, 0);
495
0
            continue;
496
0
        }
497
44.7k
        int32_t top_level_id = -1;
498
44.7k
        if (to_lower(path.front()) != to_lower(column->name) &&
499
44.7k
            (!parse_non_negative_int(path.front(), &top_level_id) ||
500
21.6k
             !column->has_identifier_field_id() ||
501
21.6k
             top_level_id != column->get_identifier_field_id())) {
502
2
            return Status::NotSupported("AccessPathParser access path {} does not match slot {}",
503
2
                                        access_path_to_string(path), column->name);
504
2
        }
505
44.7k
        insert_access_path(&root, path, 1);
506
44.7k
    }
507
    // Recursively build nested children for the column based on the AccessPathNode tree.
508
88.4k
    return build_nested_children_from_access_node(column, column->type, root, column->name,
509
88.4k
                                                  schema_column, prefer_exact_name_match);
510
88.4k
}
511
512
Status AccessPathParser::build_nested_children(format::ColumnDefinition* column,
513
                                               const SlotDescriptor* slot_desc,
514
                                               const format::ColumnDefinition* schema_column,
515
239k
                                               bool prefer_exact_name_match) {
516
239k
    DORIS_CHECK(column != nullptr);
517
239k
    DORIS_CHECK(slot_desc != nullptr);
518
239k
    return build_nested_children(column, slot_desc->all_access_paths(), schema_column,
519
239k
                                 prefer_exact_name_match);
520
239k
}
521
522
} // namespace doris