Coverage Report

Created: 2026-03-15 20:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/udf/python/python_udf_meta.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 <sys/types.h>
21
22
#include "arrow/buffer.h"
23
#include "arrow/flight/client.h"
24
#include "arrow/flight/server.h"
25
#include "common/status.h"
26
#include "core/data_type/data_type.h"
27
#include "format/arrow/arrow_row_batch.h"
28
29
namespace doris {
30
31
enum class PythonUDFLoadType : uint8_t { INLINE = 0, MODULE = 1, UNKNOWN = 2 };
32
33
enum class PythonClientType : uint8_t { UDF = 0, UDAF = 1, UDTF = 2, UNKNOWN = 3 };
34
35
struct PythonUDFMeta {
36
    int64_t id;
37
    std::string name;
38
    std::string symbol;
39
    std::string location;
40
    std::string checksum;
41
    std::string runtime_version;
42
    std::string inline_code;
43
    bool always_nullable;
44
    DataTypes input_types;
45
    DataTypePtr return_type;
46
    PythonUDFLoadType type;
47
    PythonClientType client_type;
48
49
    static Status convert_types_to_schema(const DataTypes& types, const std::string& timezone,
50
                                          std::shared_ptr<arrow::Schema>* schema);
51
52
    static Status serialize_arrow_schema(const std::shared_ptr<arrow::Schema>& schema,
53
                                         std::shared_ptr<arrow::Buffer>* out);
54
55
    Status serialize_to_json(std::string* json_str) const;
56
57
    std::string to_string() const;
58
59
    Status check() const;
60
61
2
    bool operator==(const PythonUDFMeta& other) const { return id == other.id; }
62
};
63
64
} // namespace doris
65
66
namespace std {
67
template <>
68
struct hash<doris::PythonUDFMeta> {
69
4
    size_t operator()(const doris::PythonUDFMeta& meta) const {
70
4
        return std::hash<int64_t>()(meta.id);
71
4
    }
72
};
73
} // namespace std