Coverage Report

Created: 2026-08-18 22:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format_v2/column_mapper_nested.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 <span>
22
#include <string>
23
#include <vector>
24
25
#include "common/status.h"
26
#include "core/data_type/data_type.h"
27
#include "core/field.h"
28
#include "exprs/vexpr_fwd.h"
29
#include "exprs/vliteral.h"
30
#include "exprs/vslot_ref.h"
31
#include "format_v2/column_mapper.h"
32
#include "format_v2/file_reader.h"
33
34
namespace doris::format {
35
36
struct StructChildSelector {
37
    bool is_array_element = false;
38
    bool by_name = true;
39
    std::string name;
40
    size_t ordinal = 0;
41
};
42
43
struct NestedStructPath {
44
    GlobalIndex root_global_index;
45
    DataTypePtr root_table_type;
46
    std::vector<StructChildSelector> selectors;
47
};
48
49
struct ResolvedNestedStructPath {
50
    LocalColumnIndex file_projection;
51
    std::vector<std::string> file_child_names;
52
    std::vector<DataTypePtr> file_child_types;
53
    std::vector<DataTypePtr> table_child_types;
54
    std::vector<bool> file_array_elements;
55
};
56
57
// A split-local literal produced by slot-literal predicate localization. This wrapper keeps the
58
// original table literal so a cloned conjunct can be localized again for another split.
59
class SplitLocalFileLiteral final : public VLiteral {
60
public:
61
    SplitLocalFileLiteral(const DataTypePtr& file_type, const Field& file_field,
62
                          DataTypePtr original_type, Field original_field);
63
64
0
    const DataTypePtr& original_type() const { return _original_type; }
65
0
    const Field& original_field() const { return _original_field; }
66
0
    Status clone_node(VExprSPtr* cloned_expr) const override {
67
0
        DORIS_CHECK(cloned_expr != nullptr);
68
0
        Field file_field;
69
0
        get_column_ptr()->get(0, file_field);
70
0
        *cloned_expr = std::make_shared<SplitLocalFileLiteral>(_data_type, file_field,
71
0
                                                               _original_type, _original_field);
72
0
        return Status::OK();
73
0
    }
74
75
private:
76
    DataTypePtr _original_type;
77
    Field _original_field;
78
};
79
80
GlobalIndex slot_ref_global_index(const VSlotRef& slot_ref);
81
bool is_struct_element_expr(const VExprSPtr& expr);
82
Field literal_field(const VExprSPtr& literal_expr);
83
84
bool resolve_nested_struct_path_for_file(const NestedStructPath& path,
85
                                         const std::vector<ColumnMapping>& mappings,
86
                                         ResolvedNestedStructPath* resolved,
87
                                         bool require_scan_projection = false);
88
89
bool resolve_nested_struct_expr_for_file(const VExprSPtr& expr,
90
                                         const std::vector<ColumnMapping>& mappings,
91
                                         ResolvedNestedStructPath* resolved);
92
93
std::vector<const ColumnMapping*> present_child_mappings_in_file_order(
94
        const std::vector<ColumnMapping>& child_mappings);
95
96
Status build_file_child_projection_from_schema(const std::vector<ColumnDefinition>& children,
97
                                               std::span<const StructChildSelector> selectors,
98
                                               LocalColumnIndex* projection);
99
100
} // namespace doris::format