Coverage Report

Created: 2024-11-21 13:15

/root/doris/be/src/util/arrow/utils.cpp
Line
Count
Source (jump to first uncovered line)
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 "util/arrow/utils.h"
19
20
#include <arrow/pretty_print.h>
21
#include <arrow/status.h>
22
23
#include "gutil/strings/substitute.h"
24
25
namespace doris {
26
27
0
Status to_doris_status(const arrow::Status& status) {
28
0
    if (status.ok()) {
29
0
        return Status::OK();
30
0
    } else {
31
0
        return Status::InvalidArgument(status.ToString());
32
0
    }
33
0
}
34
35
0
arrow::Status to_arrow_status(const Status& status) {
36
0
    if (LIKELY(status.ok())) {
37
0
        return arrow::Status::OK();
38
0
    } else {
39
0
        LOG(WARNING) << status.to_string();
40
        // The length of exception msg returned to the ADBC Client cannot larger than 8192,
41
        // otherwise ADBC Client will receive:
42
        // `INTERNAL: http2 exception Header size exceeded max allowed size (8192)`.
43
0
        return arrow::Status::Invalid(status.to_string_no_stack());
44
0
    }
45
0
}
46
47
0
Status arrow_pretty_print(const arrow::RecordBatch& rb, std::ostream* os) {
48
0
    return to_doris_status(arrow::PrettyPrint(rb, 0, os));
49
0
}
50
51
0
Status arrow_pretty_print(const arrow::Array& arr, std::ostream* os) {
52
0
    arrow::PrettyPrintOptions opts(4);
53
0
    return to_doris_status(arrow::PrettyPrint(arr, opts, os));
54
0
}
55
56
} // namespace doris