Coverage Report

Created: 2026-03-31 18:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/io_helper.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/registerFunctionsComparison.cpp
19
// and modified by Doris
20
21
#include "util/io_helper.h"
22
23
#include "core/binary_cast.hpp"
24
#include "exprs/function/cast/cast_to_date_or_datetime_impl.hpp"
25
#include "exprs/function/cast/cast_to_datetimev2_impl.hpp"
26
#include "exprs/function/cast/cast_to_datev2_impl.hpp"
27
28
namespace doris {
29
29.7k
bool read_date_text_impl(VecDateTimeValue& x, const StringRef& buf) {
30
29.7k
    CastParameters params;
31
29.7k
    auto ans = CastToDateOrDatetime::from_string_non_strict_mode<DatelikeTargetType::DATE>(
32
29.7k
            buf, x, nullptr, params);
33
29.7k
    x.cast_to_date();
34
29.7k
    return ans;
35
29.7k
}
36
37
35.8k
bool read_datetime_text_impl(VecDateTimeValue& x, const StringRef& buf) {
38
35.8k
    CastParameters params;
39
35.8k
    auto ans = CastToDateOrDatetime::from_string_non_strict_mode<DatelikeTargetType::DATE_TIME>(
40
35.8k
            buf, x, nullptr, params);
41
35.8k
    x.to_datetime();
42
35.8k
    return ans;
43
35.8k
}
44
45
0
bool read_date_text_impl(Int64& x, const StringRef& buf, const cctz::time_zone& local_time_zone) {
46
0
    auto dv = binary_cast<Int64, VecDateTimeValue>(x);
47
0
    CastParameters params;
48
0
    auto ans = CastToDateOrDatetime::from_string_non_strict_mode<DatelikeTargetType::DATE>(
49
0
            buf, dv, &local_time_zone, params);
50
0
    dv.cast_to_date();
51
0
    x = binary_cast<VecDateTimeValue, Int64>(dv);
52
0
    return ans;
53
0
}
54
55
bool read_datetime_text_impl(Int64& x, const StringRef& buf,
56
0
                             const cctz::time_zone& local_time_zone) {
57
0
    auto dv = binary_cast<Int64, VecDateTimeValue>(x);
58
0
    CastParameters params;
59
0
    auto ans = CastToDateOrDatetime::from_string_non_strict_mode<DatelikeTargetType::DATE_TIME>(
60
0
            buf, dv, &local_time_zone, params);
61
0
    dv.to_datetime();
62
0
    x = binary_cast<VecDateTimeValue, Int64>(dv);
63
0
    return ans;
64
0
}
65
66
25.6k
bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf) {
67
25.6k
    CastParameters params;
68
25.6k
    return CastToDateV2::from_string_non_strict_mode(buf, x, nullptr, params);
69
25.6k
}
70
71
bool read_date_v2_text_impl(DateV2Value<DateV2ValueType>& x, const StringRef& buf,
72
0
                            const cctz::time_zone& local_time_zone) {
73
0
    CastParameters params;
74
0
    return CastToDateV2::from_string_non_strict_mode(buf, x, &local_time_zone, params);
75
0
}
76
77
bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf,
78
142k
                                UInt32 scale) {
79
142k
    CastParameters params;
80
142k
    return CastToDatetimeV2::from_string_non_strict_mode(buf, x, nullptr, scale, params);
81
142k
}
82
83
bool read_datetime_v2_text_impl(DateV2Value<DateTimeV2ValueType>& x, const StringRef& buf,
84
0
                                const cctz::time_zone& local_time_zone, UInt32 scale) {
85
0
    CastParameters params;
86
0
    return CastToDatetimeV2::from_string_non_strict_mode(buf, x, &local_time_zone, scale, params);
87
0
}
88
89
} // namespace doris