Coverage Report

Created: 2026-10-17 12:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/agent/be_exec_version_manager.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 <fmt/format.h>
21
#include <glog/logging.h>
22
23
#include <map>
24
#include <set>
25
#include <string>
26
27
#include "common/exception.h"
28
#include "common/status.h"
29
30
namespace doris {
31
32
// Version 8 removed the old implementations of these restricted aggregate functions.
33
constexpr inline int SUPPORT_RESTRICTED_AGGREGATES_VERSION = 8;
34
constexpr inline int USE_NEW_FIXED_OBJECT_SERIALIZATION_VERSION = 10;
35
constexpr inline int SUPPORT_ICEBERG_MERGE_CARDINALITY_VERSION = 11;
36
constexpr inline int SUPPORT_ICEBERG_VARIANT_VERSION = 12;
37
constexpr inline int SUPPORT_EXTERNAL_TABLE_SINK_HASH_VERSION = 13;
38
constexpr inline int SUPPORT_TIMESTAMP_NS_VERSION = 14;
39
constexpr inline int SUPPORT_HIVE_OPEN_CSV_VERSION = 15;
40
constexpr inline int SUPPORT_PAIMON_WRITE_VERSION = 16;
41
constexpr inline int SUPPORT_MAP_AGG_V2_EXACT_FRAME_VERSION = 17;
42
constexpr inline int SUPPORT_ICEBERG_TRANSFORM_ROUTING_VERSION = 18;
43
constexpr inline int SUPPORT_VARBINARY_SHUFFLE_HASH_VERSION = 19;
44
45
class BeExecVersionManager {
46
public:
47
    BeExecVersionManager() = delete;
48
49
    static Status check_be_exec_version(int be_exec_version);
50
51
    static int get_function_compatibility(int be_exec_version, std::string function_name);
52
53
    static int get_function_alternative(int be_exec_version, std::string function_name);
54
55
    static void check_function_restriction(int be_exec_version, const std::string& function_name);
56
57
    static void check_function_compatibility(int current_be_exec_version, int data_be_exec_version,
58
                                             std::string function_name);
59
60
4.21M
    static int get_newest_version() { return max_be_exec_version; }
61
62
95
    static std::string get_function_suffix(int be_exec_version) {
63
95
        return "_for_old_version_" + std::to_string(be_exec_version);
64
95
    }
65
66
    // For example, there are incompatible changes between version=7 and version=6, at this time breaking_old_version is 6.
67
    static void registe_old_function_compatibility(int breaking_old_version,
68
0
                                                   std::string function_name) {
69
0
        _function_change_map[function_name].insert(breaking_old_version);
70
0
        register_old_function_alternative(breaking_old_version, function_name);
71
0
    }
72
73
    static void register_old_function_alternative(int breaking_old_version,
74
10
                                                  std::string function_name) {
75
10
        _function_alternative_map[function_name].insert(breaking_old_version);
76
10
    }
77
78
    static void registe_restrict_function_compatibility(std::string function_name,
79
32
                                                        int first_supported_version) {
80
32
        _function_restrict_map.emplace(function_name, first_supported_version);
81
32
    }
82
83
private:
84
    static const int max_be_exec_version;
85
    static const int min_be_exec_version;
86
    // [function name] -> [breaking change start version]
87
    static std::map<std::string, std::set<int>> _function_change_map;
88
    // [function name] -> [alternative implementation start version]
89
    static std::map<std::string, std::set<int>> _function_alternative_map;
90
    // [function name] -> [first BE exec version with the retained implementation]
91
    static std::map<std::string, int> _function_restrict_map;
92
};
93
94
} // namespace doris