Coverage Report

Created: 2026-09-29 12:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/date_time_transforms.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
// This file is copied from
18
// https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/DateTimeTransforms.h
19
// and modified by Doris
20
21
#pragma once
22
23
#include <libdivide.h>
24
25
#include <cmath>
26
#include <cstdint>
27
28
#include "common/status.h"
29
#include "core/binary_cast.hpp"
30
#include "core/block/block.h"
31
#include "core/block/column_numbers.h"
32
#include "core/column/column.h"
33
#include "core/column/column_decimal.h"
34
#include "core/column/column_nullable.h"
35
#include "core/column/column_string.h"
36
#include "core/column/column_vector.h"
37
#include "core/data_type/data_type_date.h"
38
#include "core/data_type/data_type_date_time.h"
39
#include "core/data_type/data_type_decimal.h"
40
#include "core/data_type/data_type_string.h"
41
#include "core/data_type/define_primitive_type.h"
42
#include "core/data_type/primitive_type.h"
43
#include "core/types.h"
44
#include "core/value/time_value.h"
45
#include "core/value/vdatetime_value.h"
46
#include "exec/common/int_exp.h"
47
#include "exec/common/util.hpp"
48
#include "exprs/function/date_format_type.h"
49
#include "exprs/function_context.h"
50
51
// FIXME: This file contains widespread UB due to unsafe type-punning casts.
52
//        These must be properly refactored to eliminate reliance on reinterpret-style behavior.
53
//
54
// Temporarily suppress GCC 15+ warnings on user-defined type casts to allow build to proceed.
55
#if defined(__GNUC__) && (__GNUC__ >= 15)
56
#pragma GCC diagnostic push
57
#pragma GCC diagnostic ignored "-Wcast-user-defined"
58
#endif
59
60
namespace doris {
61
62
#define TIME_FUNCTION_IMPL(CLASS, UNIT, FUNCTION)                                       \
63
    template <PrimitiveType PType>                                                      \
64
    struct CLASS {                                                                      \
65
        static constexpr PrimitiveType OpArgType = PType;                               \
66
        using CppType = typename PrimitiveTypeTraits<PType>::CppType;                   \
67
        static constexpr auto name = #UNIT;                                             \
68
                                                                                        \
69
12.4k
        static inline auto execute(const CppType& date_time_value) {                    \
70
12.4k
            return date_time_value.FUNCTION;                                            \
71
12.4k
        }                                                                               \
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
2
        static inline auto execute(const CppType& date_time_value) {                    \
70
2
            return date_time_value.FUNCTION;                                            \
71
2
        }                                                                               \
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
2
        static inline auto execute(const CppType& date_time_value) {                    \
70
2
            return date_time_value.FUNCTION;                                            \
71
2
        }                                                                               \
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
2
        static inline auto execute(const CppType& date_time_value) {                    \
70
2
            return date_time_value.FUNCTION;                                            \
71
2
        }                                                                               \
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
10
        static inline auto execute(const CppType& date_time_value) {                    \
70
10
            return date_time_value.FUNCTION;                                            \
71
10
        }                                                                               \
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
Unexecuted instantiation: _ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris11WeekDayImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
69
4
        static inline auto execute(const CppType& date_time_value) {                    \
70
4
            return date_time_value.FUNCTION;                                            \
71
4
        }                                                                               \
Unexecuted instantiation: _ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
10
        static inline auto execute(const CppType& date_time_value) {                    \
70
10
            return date_time_value.FUNCTION;                                            \
71
10
        }                                                                               \
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
10
        static inline auto execute(const CppType& date_time_value) {                    \
70
10
            return date_time_value.FUNCTION;                                            \
71
10
        }                                                                               \
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
12.2k
        static inline auto execute(const CppType& date_time_value) {                    \
70
12.2k
            return date_time_value.FUNCTION;                                            \
71
12.2k
        }                                                                               \
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
Unexecuted instantiation: _ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Unexecuted instantiation: _ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris12ToSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
Unexecuted instantiation: _ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris10ToHourImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris9ToDayImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris11ToMonthImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Line
Count
Source
69
6
        static inline auto execute(const CppType& date_time_value) {                    \
70
6
            return date_time_value.FUNCTION;                                            \
71
6
        }                                                                               \
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Line
Count
Source
69
8
        static inline auto execute(const CppType& date_time_value) {                    \
70
8
            return date_time_value.FUNCTION;                                            \
71
8
        }                                                                               \
Unexecuted instantiation: _ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Unexecuted instantiation: _ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
72
                                                                                        \
73
88
        static DataTypes get_variadic_argument_types() {                                \
74
88
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
88
        }                                                                               \
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
_ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
73
2
        static DataTypes get_variadic_argument_types() {                                \
74
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \
75
2
        }                                                                               \
76
    }
77
78
#define TO_TIME_FUNCTION(CLASS, UNIT) TIME_FUNCTION_IMPL(CLASS, UNIT, UNIT())
79
80
TO_TIME_FUNCTION(ToYearImpl, year);
81
template <PrimitiveType PType>
82
struct ToCenturyImpl {
83
    static constexpr PrimitiveType OpArgType = PType;
84
    using CppType = typename PrimitiveTypeTraits<PType>::CppType;
85
    static constexpr auto name = "century";
86
87
62
    static inline auto execute(const CppType& t) {
88
62
        const auto& date_time_value = t;
89
62
        int year = date_time_value.year();
90
62
        return (year - 1) / 100 + 1;
91
62
    }
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
87
8
    static inline auto execute(const CppType& t) {
88
8
        const auto& date_time_value = t;
89
8
        int year = date_time_value.year();
90
8
        return (year - 1) / 100 + 1;
91
8
    }
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
87
54
    static inline auto execute(const CppType& t) {
88
54
        const auto& date_time_value = t;
89
54
        int year = date_time_value.year();
90
54
        return (year - 1) / 100 + 1;
91
54
    }
Unexecuted instantiation: _ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
92
93
6
    static DataTypes get_variadic_argument_types() {
94
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
95
6
    }
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
93
2
    static DataTypes get_variadic_argument_types() {
94
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
95
2
    }
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
93
2
    static DataTypes get_variadic_argument_types() {
94
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
95
2
    }
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
93
2
    static DataTypes get_variadic_argument_types() {
94
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
95
2
    }
96
};
97
TO_TIME_FUNCTION(ToYearOfWeekImpl, year_of_week);
98
TO_TIME_FUNCTION(ToQuarterImpl, quarter);
99
TO_TIME_FUNCTION(ToMonthImpl, month);
100
TO_TIME_FUNCTION(ToDayImpl, day);
101
TO_TIME_FUNCTION(ToHourImpl, hour);
102
TO_TIME_FUNCTION(ToMinuteImpl, minute);
103
TO_TIME_FUNCTION(ToSecondImpl, second);
104
TO_TIME_FUNCTION(ToMicroSecondImpl, microsecond);
105
template <PrimitiveType PType>
106
struct ToNanoSecondImpl {
107
    static constexpr PrimitiveType OpArgType = PType;
108
    using CppType = typename PrimitiveTypeTraits<PType>::CppType;
109
    static constexpr auto name = "nanosecond";
110
111
22
    static inline auto execute(const CppType& date_time_value) {
112
22
        if constexpr (PType == TYPE_TIMESTAMP_NS) {
113
8
            return date_time_value.nanosecond();
114
14
        } else {
115
14
            return static_cast<uint32_t>(date_time_value.microsecond()) *
116
14
                   static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND);
117
14
        }
118
22
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
111
6
    static inline auto execute(const CppType& date_time_value) {
112
        if constexpr (PType == TYPE_TIMESTAMP_NS) {
113
            return date_time_value.nanosecond();
114
6
        } else {
115
6
            return static_cast<uint32_t>(date_time_value.microsecond()) *
116
6
                   static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND);
117
6
        }
118
6
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
111
8
    static inline auto execute(const CppType& date_time_value) {
112
        if constexpr (PType == TYPE_TIMESTAMP_NS) {
113
            return date_time_value.nanosecond();
114
8
        } else {
115
8
            return static_cast<uint32_t>(date_time_value.microsecond()) *
116
8
                   static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND);
117
8
        }
118
8
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Line
Count
Source
111
8
    static inline auto execute(const CppType& date_time_value) {
112
8
        if constexpr (PType == TYPE_TIMESTAMP_NS) {
113
8
            return date_time_value.nanosecond();
114
        } else {
115
            return static_cast<uint32_t>(date_time_value.microsecond()) *
116
                   static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND);
117
        }
118
8
    }
119
120
6
    static DataTypes get_variadic_argument_types() {
121
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
122
6
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
120
2
    static DataTypes get_variadic_argument_types() {
121
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
122
2
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
120
2
    static DataTypes get_variadic_argument_types() {
121
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
122
2
    }
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
120
2
    static DataTypes get_variadic_argument_types() {
121
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
122
2
    }
123
};
124
125
TIME_FUNCTION_IMPL(WeekOfYearImpl, weekofyear, week(mysql_week_mode(3)));
126
TIME_FUNCTION_IMPL(DayOfYearImpl, dayofyear, day_of_year());
127
TIME_FUNCTION_IMPL(DayOfMonthImpl, dayofmonth, day());
128
TIME_FUNCTION_IMPL(DayOfWeekImpl, dayofweek, day_of_week());
129
TIME_FUNCTION_IMPL(WeekDayImpl, weekday, weekday());
130
// TODO: the method should be always not nullable
131
TIME_FUNCTION_IMPL(ToDaysImpl, to_days, daynr());
132
TIME_FUNCTION_IMPL(ToSecondsImpl, to_seconds,
133
                   daynr() * 86400L + date_time_value.time_part_to_seconds());
134
135
#define TIME_FUNCTION_ONE_ARG_IMPL(CLASS, UNIT, FUNCTION)                                     \
136
    template <PrimitiveType PType>                                                            \
137
    struct CLASS {                                                                            \
138
        static constexpr PrimitiveType OpArgType = PType;                                     \
139
        using ArgType = typename PrimitiveTypeTraits<PType>::CppType;                         \
140
        static constexpr auto name = #UNIT;                                                   \
141
                                                                                              \
142
24
        static inline auto execute(const ArgType& t) {                                        \
143
24
            const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \
144
24
            return date_time_value.FUNCTION;                                                  \
145
24
        }                                                                                     \
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
142
4
        static inline auto execute(const ArgType& t) {                                        \
143
4
            const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \
144
4
            return date_time_value.FUNCTION;                                                  \
145
4
        }                                                                                     \
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
142
8
        static inline auto execute(const ArgType& t) {                                        \
143
8
            const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \
144
8
            return date_time_value.FUNCTION;                                                  \
145
8
        }                                                                                     \
Unexecuted instantiation: _ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
142
4
        static inline auto execute(const ArgType& t) {                                        \
143
4
            const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \
144
4
            return date_time_value.FUNCTION;                                                  \
145
4
        }                                                                                     \
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
142
8
        static inline auto execute(const ArgType& t) {                                        \
143
8
            const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \
144
8
            return date_time_value.FUNCTION;                                                  \
145
8
        }                                                                                     \
Unexecuted instantiation: _ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
146
                                                                                              \
147
12
        static DataTypes get_variadic_argument_types() {                                      \
148
12
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
12
        }                                                                                     \
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
147
2
        static DataTypes get_variadic_argument_types() {                                      \
148
2
            return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};       \
149
2
        }                                                                                     \
150
    }
151
152
TIME_FUNCTION_ONE_ARG_IMPL(ToWeekOneArgImpl, week, week(mysql_week_mode(0)));
153
TIME_FUNCTION_ONE_ARG_IMPL(ToYearWeekOneArgImpl, yearweek, year_week(mysql_week_mode(0)));
154
155
template <PrimitiveType PType>
156
struct ToDateImpl {
157
    static constexpr PrimitiveType OpArgType = PType;
158
    using DateType = typename PrimitiveTypeTraits<PType>::CppType;
159
    static constexpr auto name = "to_date";
160
161
16
    static auto execute(const DateType& t) {
162
16
        if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) {
163
4
            return t;
164
        } else if constexpr (std::is_same_v<DateType, VecDateTimeValue>) {
165
            t.cast_to_date();
166
            return t;
167
6
        } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) {
168
6
            return t.to_date();
169
6
        } else {
170
6
            return binary_cast<UInt32, DateV2Value<DateV2ValueType>>(
171
6
                    (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH));
172
6
        }
173
16
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
Line
Count
Source
161
4
    static auto execute(const DateType& t) {
162
4
        if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) {
163
4
            return t;
164
        } else if constexpr (std::is_same_v<DateType, VecDateTimeValue>) {
165
            t.cast_to_date();
166
            return t;
167
        } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) {
168
            return t.to_date();
169
        } else {
170
            return binary_cast<UInt32, DateV2Value<DateV2ValueType>>(
171
                    (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH));
172
        }
173
4
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
161
6
    static auto execute(const DateType& t) {
162
        if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) {
163
            return t;
164
        } else if constexpr (std::is_same_v<DateType, VecDateTimeValue>) {
165
            t.cast_to_date();
166
            return t;
167
        } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) {
168
            return t.to_date();
169
6
        } else {
170
6
            return binary_cast<UInt32, DateV2Value<DateV2ValueType>>(
171
6
                    (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH));
172
6
        }
173
6
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
Line
Count
Source
161
6
    static auto execute(const DateType& t) {
162
        if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) {
163
            return t;
164
        } else if constexpr (std::is_same_v<DateType, VecDateTimeValue>) {
165
            t.cast_to_date();
166
            return t;
167
6
        } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) {
168
6
            return t.to_date();
169
        } else {
170
            return binary_cast<UInt32, DateV2Value<DateV2ValueType>>(
171
                    (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH));
172
        }
173
6
    }
174
175
12
    static DataTypes get_variadic_argument_types() {
176
12
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
177
12
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
175
4
    static DataTypes get_variadic_argument_types() {
176
4
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
177
4
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
175
4
    static DataTypes get_variadic_argument_types() {
176
4
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
177
4
    }
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
175
4
    static DataTypes get_variadic_argument_types() {
176
4
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
177
4
    }
178
};
179
180
template <PrimitiveType ArgType>
181
struct DateImpl : public ToDateImpl<ArgType> {
182
    static constexpr auto name = "date";
183
};
184
185
// TODO: This function look like no need do indeed copy here, we should optimize this function
186
template <PrimitiveType PType>
187
struct TimeStampImpl {
188
    static constexpr PrimitiveType OpArgType = PType;
189
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
190
    static constexpr auto name = "timestamp";
191
192
0
    static auto execute(const ArgType& t) { return t; }
Unexecuted instantiation: _ZN5doris13TimeStampImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Unexecuted instantiation: _ZN5doris13TimeStampImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE
193
194
4
    static DataTypes get_variadic_argument_types() {
195
4
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
196
4
    }
_ZN5doris13TimeStampImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
194
2
    static DataTypes get_variadic_argument_types() {
195
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
196
2
    }
_ZN5doris13TimeStampImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
194
2
    static DataTypes get_variadic_argument_types() {
195
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
196
2
    }
197
};
198
199
template <PrimitiveType PType>
200
struct DayNameImpl {
201
    static constexpr PrimitiveType OpArgType = PType;
202
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
203
    static constexpr auto name = "dayname";
204
    static constexpr auto max_size = MAX_DAY_NAME_LEN;
205
206
    static auto execute(const typename PrimitiveTypeTraits<PType>::CppType& dt,
207
                        ColumnString::Chars& res_data, size_t& offset, const char* const* day_names,
208
6
                        FunctionContext* /*context*/) {
209
6
        DCHECK(day_names != nullptr);
210
6
        const auto* day_name = dt.day_name_with_locale(day_names);
211
6
        if (day_name != nullptr) {
212
6
            auto len = strlen(day_name);
213
6
            memcpy(&res_data[offset], day_name, len);
214
6
            offset += len;
215
6
        }
216
6
        return offset;
217
6
    }
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Line
Count
Source
208
2
                        FunctionContext* /*context*/) {
209
2
        DCHECK(day_names != nullptr);
210
2
        const auto* day_name = dt.day_name_with_locale(day_names);
211
2
        if (day_name != nullptr) {
212
2
            auto len = strlen(day_name);
213
2
            memcpy(&res_data[offset], day_name, len);
214
2
            offset += len;
215
2
        }
216
2
        return offset;
217
2
    }
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Line
Count
Source
208
4
                        FunctionContext* /*context*/) {
209
4
        DCHECK(day_names != nullptr);
210
4
        const auto* day_name = dt.day_name_with_locale(day_names);
211
4
        if (day_name != nullptr) {
212
4
            auto len = strlen(day_name);
213
4
            memcpy(&res_data[offset], day_name, len);
214
4
            offset += len;
215
4
        }
216
4
        return offset;
217
4
    }
Unexecuted instantiation: _ZN5doris11DayNameImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
218
219
6
    static DataTypes get_variadic_argument_types() {
220
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
221
6
    }
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
219
2
    static DataTypes get_variadic_argument_types() {
220
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
221
2
    }
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
219
2
    static DataTypes get_variadic_argument_types() {
220
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
221
2
    }
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
219
2
    static DataTypes get_variadic_argument_types() {
220
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
221
2
    }
222
};
223
224
template <PrimitiveType PType>
225
struct ToIso8601Impl {
226
    static constexpr PrimitiveType OpArgType = PType;
227
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
228
    static constexpr auto name = "to_iso8601";
229
    static constexpr auto max_size = [] {
230
        if constexpr (PType == TYPE_DATEV2) {
231
            return 10;
232
        } else if constexpr (PType == TYPE_TIMESTAMP_NS) {
233
            return 29;
234
        } else {
235
            return 26;
236
        }
237
    }();
238
239
    static auto execute(const typename PrimitiveTypeTraits<PType>::CppType& dt,
240
                        ColumnString::Chars& res_data, size_t& offset,
241
0
                        const char* const* /*names_ptr*/, FunctionContext* /*context*/) {
242
0
        int length = 0;
243
0
        if constexpr (PType == TYPE_TIMESTAMP_NS) {
244
0
            length = dt.to_buffer((char*)res_data.data() + offset);
245
0
        } else {
246
0
            constexpr int scale = PType == TYPE_DATEV2 ? -1 : 6;
247
0
            length = dt.to_buffer((char*)res_data.data() + offset, scale);
248
0
        }
249
0
        if (PType == TYPE_DATETIMEV2 || PType == TYPE_TIMESTAMP_NS || PType == TYPE_TIMESTAMPTZ) {
250
0
            res_data[offset + 10] = 'T';
251
0
        }
252
253
0
        offset += length;
254
0
        return offset;
255
0
    }
Unexecuted instantiation: _ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
256
257
6
    static DataTypes get_variadic_argument_types() {
258
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
259
6
    }
_ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
257
2
    static DataTypes get_variadic_argument_types() {
258
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
259
2
    }
_ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
257
2
    static DataTypes get_variadic_argument_types() {
258
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
259
2
    }
_ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
257
2
    static DataTypes get_variadic_argument_types() {
258
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
259
2
    }
260
};
261
262
// Specialization for TIMESTAMPTZ type
263
template <>
264
struct ToIso8601Impl<TYPE_TIMESTAMPTZ> {
265
    static constexpr PrimitiveType OpArgType = TYPE_TIMESTAMPTZ;
266
    using ArgType = typename PrimitiveTypeTraits<TYPE_TIMESTAMPTZ>::CppType;
267
    static constexpr auto name = "to_iso8601";
268
    // Format: YYYY-MM-DDTHH:MM:SS.SSSSSS+HH:MM
269
    static constexpr auto max_size = 32;
270
271
    static auto execute(const TimestampTzValue& tz_value, ColumnString::Chars& res_data,
272
                        size_t& offset, const char* const* /*names_ptr*/,
273
0
                        FunctionContext* context) {
274
        // Get timezone
275
0
        const auto& local_time_zone = context->state()->timezone_obj();
276
277
        // Convert UTC time to local time
278
0
        cctz::civil_second utc_sec(tz_value.year(), tz_value.month(), tz_value.day(),
279
0
                                   tz_value.hour(), tz_value.minute(), tz_value.second());
280
0
        cctz::time_point<cctz::seconds> local_time = cctz::convert(utc_sec, cctz::utc_time_zone());
281
282
0
        auto lookup_result = local_time_zone.lookup(local_time);
283
0
        cctz::civil_second civ = lookup_result.cs;
284
0
        auto time_offset = lookup_result.offset;
285
286
0
        int offset_hours = time_offset / 3600;
287
0
        int offset_mins = (std::abs(time_offset) % 3600) / 60;
288
289
        // Create local datetime value
290
0
        DateV2Value<DateTimeV2ValueType> local_dt;
291
0
        local_dt.unchecked_set_time((uint16_t)civ.year(), (uint8_t)civ.month(), (uint8_t)civ.day(),
292
0
                                    (uint8_t)civ.hour(), (uint8_t)civ.minute(),
293
0
                                    (uint8_t)civ.second(), tz_value.microsecond());
294
295
        // YYYY-MM-DDTHH:MM:SS.SSSSSS+HH:MM
296
0
        auto length = local_dt.to_buffer((char*)res_data.data() + offset, 6);
297
0
        res_data[offset + 10] = 'T';
298
0
        res_data[offset + length] = (offset_hours >= 0 ? '+' : '-');
299
0
        res_data[offset + length + 1] = static_cast<char>('0' + std::abs(offset_hours) / 10);
300
0
        res_data[offset + length + 2] = '0' + std::abs(offset_hours) % 10;
301
0
        res_data[offset + length + 3] = ':';
302
0
        res_data[offset + length + 4] = static_cast<char>('0' + offset_mins / 10);
303
0
        res_data[offset + length + 5] = '0' + offset_mins % 10;
304
305
0
        offset += length + 6;
306
0
        return offset;
307
0
    }
308
309
2
    static DataTypes get_variadic_argument_types() {
310
2
        return {std::make_shared<typename PrimitiveTypeTraits<TYPE_TIMESTAMPTZ>::DataType>()};
311
2
    }
312
};
313
314
template <PrimitiveType PType>
315
struct MonthNameImpl {
316
    static constexpr PrimitiveType OpArgType = PType;
317
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
318
    static constexpr auto name = "monthname";
319
    static constexpr auto max_size = MAX_MONTH_NAME_LEN;
320
321
    static auto execute(const typename PrimitiveTypeTraits<PType>::CppType& dt,
322
                        ColumnString::Chars& res_data, size_t& offset,
323
0
                        const char* const* month_names, FunctionContext* /*context*/) {
324
0
        DCHECK(month_names != nullptr);
325
0
        const auto* month_name = dt.month_name_with_locale(month_names);
326
0
        if (month_name != nullptr) {
327
0
            auto len = strlen(month_name);
328
0
            memcpy(&res_data[offset], month_name, len);
329
0
            offset += len;
330
0
        }
331
0
        return offset;
332
0
    }
Unexecuted instantiation: _ZN5doris13MonthNameImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris13MonthNameImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris13MonthNameImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE
333
334
6
    static DataTypes get_variadic_argument_types() {
335
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
336
6
    }
_ZN5doris13MonthNameImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
334
2
    static DataTypes get_variadic_argument_types() {
335
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
336
2
    }
_ZN5doris13MonthNameImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
334
2
    static DataTypes get_variadic_argument_types() {
335
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
336
2
    }
_ZN5doris13MonthNameImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
334
2
    static DataTypes get_variadic_argument_types() {
335
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
336
2
    }
337
};
338
339
template <PrimitiveType PType, typename FormatImpl, const char* FuncName>
340
struct DateTimeV2FormatImpl {
341
    static_assert(PType == TYPE_DATETIMEV2 || PType == TYPE_TIMESTAMP_NS);
342
    static constexpr PrimitiveType OpArgType = PType;
343
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
344
    static constexpr auto name = FuncName;
345
    static constexpr auto max_size = FormatImpl::row_size;
346
347
    static auto execute(const ArgType& dt, ColumnString::Chars& res_data, size_t& offset,
348
4
                        const char* const* /*names_ptr*/, FunctionContext* /*context*/) {
349
4
        auto* buf = reinterpret_cast<char*>(&res_data[offset]);
350
4
        constexpr bool needs_civil_datetime =
351
4
                std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> ||
352
4
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> ||
353
4
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> ||
354
4
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>;
355
        if constexpr (PType == TYPE_TIMESTAMP_NS &&
356
2
                      std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) {
357
2
            const auto civil_value = dt.to_date();
358
2
            offset += FormatImpl::date_to_str(civil_value, buf);
359
2
        } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) {
360
2
            const auto civil_value = dt.to_datetime();
361
2
            offset += FormatImpl::date_to_str(civil_value, buf);
362
2
        } else {
363
0
            offset += FormatImpl::date_to_str(dt, buf);
364
0
        }
365
4
        return offset;
366
4
    }
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Line
Count
Source
348
2
                        const char* const* /*names_ptr*/, FunctionContext* /*context*/) {
349
2
        auto* buf = reinterpret_cast<char*>(&res_data[offset]);
350
2
        constexpr bool needs_civil_datetime =
351
2
                std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> ||
352
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> ||
353
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> ||
354
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>;
355
        if constexpr (PType == TYPE_TIMESTAMP_NS &&
356
2
                      std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) {
357
2
            const auto civil_value = dt.to_date();
358
2
            offset += FormatImpl::date_to_str(civil_value, buf);
359
        } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) {
360
            const auto civil_value = dt.to_datetime();
361
            offset += FormatImpl::date_to_str(civil_value, buf);
362
        } else {
363
            offset += FormatImpl::date_to_str(dt, buf);
364
        }
365
2
        return offset;
366
2
    }
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Line
Count
Source
348
2
                        const char* const* /*names_ptr*/, FunctionContext* /*context*/) {
349
2
        auto* buf = reinterpret_cast<char*>(&res_data[offset]);
350
2
        constexpr bool needs_civil_datetime =
351
2
                std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> ||
352
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> ||
353
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> ||
354
2
                std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>;
355
        if constexpr (PType == TYPE_TIMESTAMP_NS &&
356
                      std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) {
357
            const auto civil_value = dt.to_date();
358
            offset += FormatImpl::date_to_str(civil_value, buf);
359
2
        } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) {
360
2
            const auto civil_value = dt.to_datetime();
361
2
            offset += FormatImpl::date_to_str(civil_value, buf);
362
        } else {
363
            offset += FormatImpl::date_to_str(dt, buf);
364
        }
365
2
        return offset;
366
2
    }
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
Unexecuted instantiation: _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPS4_PNS_15FunctionContextE
367
368
44
    static DataTypes get_variadic_argument_types() {
369
44
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
44
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE27get_variadic_argument_typesEv
Line
Count
Source
368
2
    static DataTypes get_variadic_argument_types() {
369
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()};
370
2
    }
371
};
372
373
inline constexpr char kYearMonthName[] = "year_month";
374
inline constexpr char kDayHourName[] = "day_hour";
375
inline constexpr char kDayMinuteName[] = "day_minute";
376
inline constexpr char kDaySecondName[] = "day_second";
377
inline constexpr char kDayMicrosecondName[] = "day_microsecond";
378
inline constexpr char kHourMinuteName[] = "hour_minute";
379
inline constexpr char kHourSecondName[] = "hour_second";
380
inline constexpr char kHourMicrosecondName[] = "hour_microsecond";
381
inline constexpr char kMinuteSecondName[] = "minute_second";
382
inline constexpr char kMinuteMicrosecondName[] = "minute_microsecond";
383
inline constexpr char kSecondMicrosecondName[] = "second_microsecond";
384
385
template <PrimitiveType PType>
386
using YearMonthImpl = DateTimeV2FormatImpl<PType, time_format_type::yyyy_MMImpl, kYearMonthName>;
387
template <PrimitiveType PType>
388
using DayHourImpl = DateTimeV2FormatImpl<PType, time_format_type::dd_HHImpl, kDayHourName>;
389
template <PrimitiveType PType>
390
using DayMinuteImpl = DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mmImpl, kDayMinuteName>;
391
template <PrimitiveType PType>
392
using DaySecondImpl =
393
        DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mm_ssImpl, kDaySecondName>;
394
template <PrimitiveType PType>
395
using DayMicrosecondImpl =
396
        DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mm_ss_SSSSSSImpl, kDayMicrosecondName>;
397
template <PrimitiveType PType>
398
using HourMinuteImpl = DateTimeV2FormatImpl<PType, time_format_type::HH_mmImpl, kHourMinuteName>;
399
template <PrimitiveType PType>
400
using HourSecondImpl = DateTimeV2FormatImpl<PType, time_format_type::HH_mm_ssImpl, kHourSecondName>;
401
template <PrimitiveType PType>
402
using HourMicrosecondImpl =
403
        DateTimeV2FormatImpl<PType, time_format_type::HH_mm_ss_SSSSSSImpl, kHourMicrosecondName>;
404
template <PrimitiveType PType>
405
using MinuteSecondImpl =
406
        DateTimeV2FormatImpl<PType, time_format_type::mm_ssImpl, kMinuteSecondName>;
407
template <PrimitiveType PType>
408
using MinuteMicrosecondImpl =
409
        DateTimeV2FormatImpl<PType, time_format_type::mm_ss_SSSSSSImpl, kMinuteMicrosecondName>;
410
template <PrimitiveType PType>
411
using SecondMicrosecondImpl =
412
        DateTimeV2FormatImpl<PType, time_format_type::ss_SSSSSSImpl, kSecondMicrosecondName>;
413
414
template <PrimitiveType PType>
415
struct DateFormatImpl {
416
    using DateType = typename PrimitiveTypeTraits<PType>::CppType;
417
    using ArgType = typename PrimitiveTypeTraits<PType>::CppType;
418
    static constexpr PrimitiveType FromPType = PType;
419
420
    static constexpr auto name = "date_format";
421
422
    template <typename Impl>
423
    static bool execute(const DateType& dt, StringRef format, ColumnString::Chars& res_data,
424
52
                        size_t& offset, const cctz::time_zone& time_zone) {
425
52
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
426
            // Handle non-special formats.
427
52
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
428
52
            const bool formatted = [&]() {
429
52
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
34
                    return dt.to_format_string_conservative(
431
34
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
34
                            static_cast<int>(dt.microsecond()) * 1000);
433
34
                } else {
434
18
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
18
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
18
                }
437
52
            }();
_ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Line
Count
Source
428
12
            const bool formatted = [&]() {
429
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
                    return dt.to_format_string_conservative(
431
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
                            static_cast<int>(dt.microsecond()) * 1000);
433
12
                } else {
434
12
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
12
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
12
                }
437
12
            }();
_ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Line
Count
Source
428
34
            const bool formatted = [&]() {
429
34
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
34
                    return dt.to_format_string_conservative(
431
34
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
34
                            static_cast<int>(dt.microsecond()) * 1000);
433
                } else {
434
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
                }
437
34
            }();
_ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Line
Count
Source
428
6
            const bool formatted = [&]() {
429
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
                    return dt.to_format_string_conservative(
431
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
                            static_cast<int>(dt.microsecond()) * 1000);
433
6
                } else {
434
6
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
6
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
6
                }
437
6
            }();
438
52
            if (!formatted) {
439
0
                return true;
440
0
            }
441
442
52
            auto len = strlen(buf);
443
52
            res_data.insert(buf, buf + len);
444
52
            offset += len;
445
52
            return false;
446
52
        } else {
447
0
            if (!dt.is_valid_date()) {
448
0
                return true;
449
0
            }
450
451
            // No buffer is needed here because these specially optimized formats have fixed lengths,
452
            // and sufficient memory has already been reserved.
453
0
            const auto len = [&]() {
454
0
                if constexpr (PType == TYPE_TIMESTAMP_NS) {
455
0
                    constexpr bool needs_civil_time =
456
0
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> ||
457
0
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>;
458
0
                    const auto civil_value = [&]() {
459
0
                        if constexpr (needs_civil_time) {
460
0
                            return dt.to_datetime();
461
0
                        } else {
462
0
                            return dt.to_date();
463
0
                        }
464
0
                    }();
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
Unexecuted instantiation: _ZZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEvENKUlvE_clEv
465
0
                    return Impl::date_to_str(civil_value, (char*)res_data.data() + offset);
466
0
                } else {
467
0
                    return Impl::date_to_str(dt, (char*)res_data.data() + offset);
468
0
                }
469
0
            }();
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
Unexecuted instantiation: _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv
470
0
            offset += len;
471
472
0
            return false;
473
0
        }
474
52
    }
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
424
12
                        size_t& offset, const cctz::time_zone& time_zone) {
425
12
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
426
            // Handle non-special formats.
427
12
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
428
12
            const bool formatted = [&]() {
429
12
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
12
                    return dt.to_format_string_conservative(
431
12
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
12
                            static_cast<int>(dt.microsecond()) * 1000);
433
12
                } else {
434
12
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
12
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
12
                }
437
12
            }();
438
12
            if (!formatted) {
439
0
                return true;
440
0
            }
441
442
12
            auto len = strlen(buf);
443
12
            res_data.insert(buf, buf + len);
444
12
            offset += len;
445
12
            return false;
446
        } else {
447
            if (!dt.is_valid_date()) {
448
                return true;
449
            }
450
451
            // No buffer is needed here because these specially optimized formats have fixed lengths,
452
            // and sufficient memory has already been reserved.
453
            const auto len = [&]() {
454
                if constexpr (PType == TYPE_TIMESTAMP_NS) {
455
                    constexpr bool needs_civil_time =
456
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> ||
457
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>;
458
                    const auto civil_value = [&]() {
459
                        if constexpr (needs_civil_time) {
460
                            return dt.to_datetime();
461
                        } else {
462
                            return dt.to_date();
463
                        }
464
                    }();
465
                    return Impl::date_to_str(civil_value, (char*)res_data.data() + offset);
466
                } else {
467
                    return Impl::date_to_str(dt, (char*)res_data.data() + offset);
468
                }
469
            }();
470
            offset += len;
471
472
            return false;
473
        }
474
12
    }
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
424
34
                        size_t& offset, const cctz::time_zone& time_zone) {
425
34
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
426
            // Handle non-special formats.
427
34
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
428
34
            const bool formatted = [&]() {
429
34
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
34
                    return dt.to_format_string_conservative(
431
34
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
34
                            static_cast<int>(dt.microsecond()) * 1000);
433
34
                } else {
434
34
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
34
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
34
                }
437
34
            }();
438
34
            if (!formatted) {
439
0
                return true;
440
0
            }
441
442
34
            auto len = strlen(buf);
443
34
            res_data.insert(buf, buf + len);
444
34
            offset += len;
445
34
            return false;
446
        } else {
447
            if (!dt.is_valid_date()) {
448
                return true;
449
            }
450
451
            // No buffer is needed here because these specially optimized formats have fixed lengths,
452
            // and sufficient memory has already been reserved.
453
            const auto len = [&]() {
454
                if constexpr (PType == TYPE_TIMESTAMP_NS) {
455
                    constexpr bool needs_civil_time =
456
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> ||
457
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>;
458
                    const auto civil_value = [&]() {
459
                        if constexpr (needs_civil_time) {
460
                            return dt.to_datetime();
461
                        } else {
462
                            return dt.to_date();
463
                        }
464
                    }();
465
                    return Impl::date_to_str(civil_value, (char*)res_data.data() + offset);
466
                } else {
467
                    return Impl::date_to_str(dt, (char*)res_data.data() + offset);
468
                }
469
            }();
470
            offset += len;
471
472
            return false;
473
        }
474
34
    }
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
424
6
                        size_t& offset, const cctz::time_zone& time_zone) {
425
6
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
426
            // Handle non-special formats.
427
6
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
428
6
            const bool formatted = [&]() {
429
6
                if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) {
430
6
                    return dt.to_format_string_conservative(
431
6
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN,
432
6
                            static_cast<int>(dt.microsecond()) * 1000);
433
6
                } else {
434
6
                    return dt.to_format_string_conservative(format.data, format.size, buf,
435
6
                                                            100 + SAFE_FORMAT_STRING_MARGIN);
436
6
                }
437
6
            }();
438
6
            if (!formatted) {
439
0
                return true;
440
0
            }
441
442
6
            auto len = strlen(buf);
443
6
            res_data.insert(buf, buf + len);
444
6
            offset += len;
445
6
            return false;
446
        } else {
447
            if (!dt.is_valid_date()) {
448
                return true;
449
            }
450
451
            // No buffer is needed here because these specially optimized formats have fixed lengths,
452
            // and sufficient memory has already been reserved.
453
            const auto len = [&]() {
454
                if constexpr (PType == TYPE_TIMESTAMP_NS) {
455
                    constexpr bool needs_civil_time =
456
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> ||
457
                            std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>;
458
                    const auto civil_value = [&]() {
459
                        if constexpr (needs_civil_time) {
460
                            return dt.to_datetime();
461
                        } else {
462
                            return dt.to_date();
463
                        }
464
                    }();
465
                    return Impl::date_to_str(civil_value, (char*)res_data.data() + offset);
466
                } else {
467
                    return Impl::date_to_str(dt, (char*)res_data.data() + offset);
468
                }
469
            }();
470
            offset += len;
471
472
            return false;
473
        }
474
6
    }
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type10yyyyMMImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type8yyyyImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
475
476
6
    static DataTypes get_variadic_argument_types() {
477
6
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(),
478
6
                std::make_shared<DataTypeString>()};
479
6
    }
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv
Line
Count
Source
476
2
    static DataTypes get_variadic_argument_types() {
477
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(),
478
2
                std::make_shared<DataTypeString>()};
479
2
    }
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv
Line
Count
Source
476
2
    static DataTypes get_variadic_argument_types() {
477
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(),
478
2
                std::make_shared<DataTypeString>()};
479
2
    }
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv
Line
Count
Source
476
2
    static DataTypes get_variadic_argument_types() {
477
2
        return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(),
478
2
                std::make_shared<DataTypeString>()};
479
2
    }
480
};
481
482
80
inline bool contains_from_unixtime_format_specifier(StringRef format, char specifier) {
483
670
    for (size_t i = 0; i + 1 < format.size; ++i) {
484
        // Consume the character after every '%', so "%%n" is escaped text rather than %n.
485
624
        if (format.data[i] == '%' && format.data[++i] == specifier) {
486
34
            return true;
487
34
        }
488
624
    }
489
46
    return false;
490
80
}
491
492
34
inline bool has_conflicting_from_unixtime_fraction_specifiers(StringRef format) {
493
    // %f formats the microsecond-rounded instant, while %n formats the original nanosecond
494
    // instant. For example, 0.999999500 becomes 1.000000 for %f but stays 0.999999500 for %n,
495
    // so one result cannot contain both fields consistently.
496
34
    return contains_from_unixtime_format_specifier(format, 'f') &&
497
34
           contains_from_unixtime_format_specifier(format, 'n');
498
34
}
499
500
template <bool WithStringArg, bool NewVersion = false>
501
struct FromUnixTimeImpl {
502
    using ArgType = Int64;
503
    static constexpr PrimitiveType FromPType = TYPE_BIGINT;
504
505
8
    static DataTypes get_variadic_argument_types() {
506
8
        if constexpr (WithStringArg) {
507
4
            return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()};
508
4
        } else {
509
4
            return {std::make_shared<DataTypeInt64>()};
510
4
        }
511
8
    }
_ZN5doris16FromUnixTimeImplILb0ELb0EE27get_variadic_argument_typesEv
Line
Count
Source
505
2
    static DataTypes get_variadic_argument_types() {
506
        if constexpr (WithStringArg) {
507
            return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()};
508
2
        } else {
509
2
            return {std::make_shared<DataTypeInt64>()};
510
2
        }
511
2
    }
_ZN5doris16FromUnixTimeImplILb1ELb0EE27get_variadic_argument_typesEv
Line
Count
Source
505
2
    static DataTypes get_variadic_argument_types() {
506
2
        if constexpr (WithStringArg) {
507
2
            return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()};
508
        } else {
509
            return {std::make_shared<DataTypeInt64>()};
510
        }
511
2
    }
_ZN5doris16FromUnixTimeImplILb0ELb1EE27get_variadic_argument_typesEv
Line
Count
Source
505
2
    static DataTypes get_variadic_argument_types() {
506
        if constexpr (WithStringArg) {
507
            return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()};
508
2
        } else {
509
2
            return {std::make_shared<DataTypeInt64>()};
510
2
        }
511
2
    }
_ZN5doris16FromUnixTimeImplILb1ELb1EE27get_variadic_argument_typesEv
Line
Count
Source
505
2
    static DataTypes get_variadic_argument_types() {
506
2
        if constexpr (WithStringArg) {
507
2
            return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()};
508
        } else {
509
            return {std::make_shared<DataTypeInt64>()};
510
        }
511
2
    }
512
    static const int64_t TIMESTAMP_VALID_MAX = 32536771199;
513
    static constexpr auto name = NewVersion ? "from_unixtime_new" : "from_unixtime";
514
515
24
    [[nodiscard]] static bool check_valid(const ArgType& val) {
516
24
        if constexpr (NewVersion) {
517
24
            if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] {
518
16
                return false;
519
16
            }
520
24
        } else {
521
0
            if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] {
522
0
                return false;
523
0
            }
524
0
        }
525
8
        return true;
526
24
    }
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE11check_validERKl
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE11check_validERKl
_ZN5doris16FromUnixTimeImplILb0ELb1EE11check_validERKl
Line
Count
Source
515
20
    [[nodiscard]] static bool check_valid(const ArgType& val) {
516
20
        if constexpr (NewVersion) {
517
20
            if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] {
518
16
                return false;
519
16
            }
520
        } else {
521
            if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] {
522
                return false;
523
            }
524
        }
525
4
        return true;
526
20
    }
_ZN5doris16FromUnixTimeImplILb1ELb1EE11check_validERKl
Line
Count
Source
515
4
    [[nodiscard]] static bool check_valid(const ArgType& val) {
516
4
        if constexpr (NewVersion) {
517
4
            if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] {
518
0
                return false;
519
0
            }
520
        } else {
521
            if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] {
522
                return false;
523
            }
524
        }
525
4
        return true;
526
4
    }
527
528
    static DateV2Value<DateTimeV2ValueType> get_datetime_value(const ArgType& val,
529
6
                                                               const cctz::time_zone& time_zone) {
530
6
        DateV2Value<DateTimeV2ValueType> dt;
531
6
        dt.from_unixtime(val, time_zone);
532
6
        return dt;
533
6
    }
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE18get_datetime_valueERKlRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE18get_datetime_valueERKlRKN4cctz9time_zoneE
_ZN5doris16FromUnixTimeImplILb0ELb1EE18get_datetime_valueERKlRKN4cctz9time_zoneE
Line
Count
Source
529
4
                                                               const cctz::time_zone& time_zone) {
530
4
        DateV2Value<DateTimeV2ValueType> dt;
531
4
        dt.from_unixtime(val, time_zone);
532
4
        return dt;
533
4
    }
_ZN5doris16FromUnixTimeImplILb1ELb1EE18get_datetime_valueERKlRKN4cctz9time_zoneE
Line
Count
Source
529
2
                                                               const cctz::time_zone& time_zone) {
530
2
        DateV2Value<DateTimeV2ValueType> dt;
531
2
        dt.from_unixtime(val, time_zone);
532
2
        return dt;
533
2
    }
534
535
    // return true if null(result is invalid)
536
    template <typename Impl>
537
    static bool execute(const ArgType& val, StringRef format, ColumnString::Chars& res_data,
538
24
                        size_t& offset, const cctz::time_zone& time_zone) {
539
24
        if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) {
540
18
            return true;
541
18
        }
542
6
        DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone);
543
6
        if (!dt.is_valid_date()) [[unlikely]] {
544
0
            return true;
545
0
        }
546
6
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
547
2
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
548
2
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
549
2
                                                  100 + SAFE_FORMAT_STRING_MARGIN, 0)) {
550
0
                return true;
551
0
            }
552
553
2
            auto len = strlen(buf);
554
2
            res_data.insert(buf, buf + len);
555
2
            offset += len;
556
4
        } else {
557
            // No buffer is needed here because these specially optimized formats have fixed lengths,
558
            // and sufficient memory has already been reserved.
559
4
            auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset);
560
4
            offset += len;
561
4
        }
562
0
        return false;
563
6
    }
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type15UserDefinedImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type10yyyyMMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE7executeINS_16time_format_type8yyyyImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type15UserDefinedImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type10yyyyMMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE7executeINS_16time_format_type8yyyyImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type15UserDefinedImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
_ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
538
20
                        size_t& offset, const cctz::time_zone& time_zone) {
539
20
        if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) {
540
16
            return true;
541
16
        }
542
4
        DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone);
543
4
        if (!dt.is_valid_date()) [[unlikely]] {
544
0
            return true;
545
0
        }
546
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
547
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
548
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
549
                                                  100 + SAFE_FORMAT_STRING_MARGIN, 0)) {
550
                return true;
551
            }
552
553
            auto len = strlen(buf);
554
            res_data.insert(buf, buf + len);
555
            offset += len;
556
4
        } else {
557
            // No buffer is needed here because these specially optimized formats have fixed lengths,
558
            // and sufficient memory has already been reserved.
559
4
            auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset);
560
4
            offset += len;
561
4
        }
562
4
        return false;
563
4
    }
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type10yyyyMMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb1EE7executeINS_16time_format_type8yyyyImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
_ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type15UserDefinedImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
538
4
                        size_t& offset, const cctz::time_zone& time_zone) {
539
4
        if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) {
540
2
            return true;
541
2
        }
542
2
        DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone);
543
2
        if (!dt.is_valid_date()) [[unlikely]] {
544
0
            return true;
545
0
        }
546
2
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
547
2
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
548
2
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
549
2
                                                  100 + SAFE_FORMAT_STRING_MARGIN, 0)) {
550
0
                return true;
551
0
            }
552
553
2
            auto len = strlen(buf);
554
2
            res_data.insert(buf, buf + len);
555
2
            offset += len;
556
        } else {
557
            // No buffer is needed here because these specially optimized formats have fixed lengths,
558
            // and sufficient memory has already been reserved.
559
            auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset);
560
            offset += len;
561
        }
562
0
        return false;
563
2
    }
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type12yyyyMMddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type14yyyy_MM_ddImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type23yyyy_MM_dd_HH_mm_ssImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type11yyyy_MMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type10yyyyMMImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb1EE7executeINS_16time_format_type8yyyyImplEEEbRKlNS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
564
};
565
566
// only new verison
567
template <bool WithStringArg, bool WithNanosecond = false>
568
struct FromUnixTimeDecimalImpl {
569
    static_assert(!WithNanosecond || WithStringArg);
570
    using ArgType = std::conditional_t<WithNanosecond, Int128, Int64>;
571
    static constexpr PrimitiveType FromPType = WithNanosecond ? TYPE_DECIMAL128I : TYPE_DECIMAL64;
572
    constexpr static short Scale = WithNanosecond ? 9 : 6;
573
574
6
    static DataTypes get_variadic_argument_types() {
575
6
        if constexpr (WithStringArg) {
576
4
            if constexpr (WithNanosecond) {
577
2
                return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()};
578
2
            }
579
0
            return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()};
580
4
        } else {
581
2
            return {std::make_shared<DataTypeDecimal64>()};
582
2
        }
583
6
    }
_ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE27get_variadic_argument_typesEv
Line
Count
Source
574
2
    static DataTypes get_variadic_argument_types() {
575
        if constexpr (WithStringArg) {
576
            if constexpr (WithNanosecond) {
577
                return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()};
578
            }
579
            return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()};
580
2
        } else {
581
2
            return {std::make_shared<DataTypeDecimal64>()};
582
2
        }
583
2
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE27get_variadic_argument_typesEv
Line
Count
Source
574
2
    static DataTypes get_variadic_argument_types() {
575
2
        if constexpr (WithStringArg) {
576
            if constexpr (WithNanosecond) {
577
                return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()};
578
            }
579
2
            return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()};
580
        } else {
581
            return {std::make_shared<DataTypeDecimal64>()};
582
        }
583
2
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE27get_variadic_argument_typesEv
Line
Count
Source
574
2
    static DataTypes get_variadic_argument_types() {
575
2
        if constexpr (WithStringArg) {
576
2
            if constexpr (WithNanosecond) {
577
2
                return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()};
578
2
            }
579
0
            return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()};
580
        } else {
581
            return {std::make_shared<DataTypeDecimal64>()};
582
        }
583
2
    }
584
    static constexpr auto name = "from_unixtime_new";
585
586
22
    [[nodiscard]] static bool check_valid(const ArgType& val) {
587
22
        if (val < 0) [[unlikely]] {
588
0
            return false;
589
0
        }
590
22
        return true;
591
22
    }
_ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE11check_validERKl
Line
Count
Source
586
4
    [[nodiscard]] static bool check_valid(const ArgType& val) {
587
4
        if (val < 0) [[unlikely]] {
588
0
            return false;
589
0
        }
590
4
        return true;
591
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE11check_validERKl
Line
Count
Source
586
4
    [[nodiscard]] static bool check_valid(const ArgType& val) {
587
4
        if (val < 0) [[unlikely]] {
588
0
            return false;
589
0
        }
590
4
        return true;
591
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE11check_validERKn
Line
Count
Source
586
14
    [[nodiscard]] static bool check_valid(const ArgType& val) {
587
14
        if (val < 0) [[unlikely]] {
588
0
            return false;
589
0
        }
590
14
        return true;
591
14
    }
592
593
32
    static int32_t get_nanosecond(const ArgType& fraction) {
594
32
        return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale);
595
32
    }
_ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE14get_nanosecondERKl
Line
Count
Source
593
4
    static int32_t get_nanosecond(const ArgType& fraction) {
594
4
        return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale);
595
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE14get_nanosecondERKl
Line
Count
Source
593
8
    static int32_t get_nanosecond(const ArgType& fraction) {
594
8
        return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale);
595
8
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE14get_nanosecondERKn
Line
Count
Source
593
20
    static int32_t get_nanosecond(const ArgType& fraction) {
594
20
        return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale);
595
20
    }
596
597
    static DateV2Value<DateTimeV2ValueType> get_datetime_value(const ArgType& interger,
598
                                                               const ArgType& fraction,
599
                                                               const cctz::time_zone& time_zone,
600
22
                                                               bool preserve_nanosecond) {
601
22
        auto epoch_second = static_cast<int64_t>(interger);
602
22
        int32_t nanosecond = get_nanosecond(fraction);
603
22
        if constexpr (WithNanosecond) {
604
14
            if (!preserve_nanosecond) {
605
                // Keep the established %f behavior by rounding the complete instant, including
606
                // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000.
607
10
                constexpr int32_t MICROS_PER_SECOND = 1000000;
608
10
                const int32_t rounded_microseconds =
609
10
                        (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) /
610
10
                        TimeStampNsValue::NANOS_PER_MICROSECOND;
611
10
                epoch_second += rounded_microseconds / MICROS_PER_SECOND;
612
10
                nanosecond = rounded_microseconds % MICROS_PER_SECOND *
613
10
                             TimeStampNsValue::NANOS_PER_MICROSECOND;
614
10
            }
615
14
        }
616
22
        DateV2Value<DateTimeV2ValueType> dt;
617
22
        dt.from_unixtime(epoch_second, nanosecond, time_zone, 6);
618
22
        return dt;
619
22
    }
_ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE18get_datetime_valueERKlS3_RKN4cctz9time_zoneEb
Line
Count
Source
600
4
                                                               bool preserve_nanosecond) {
601
4
        auto epoch_second = static_cast<int64_t>(interger);
602
4
        int32_t nanosecond = get_nanosecond(fraction);
603
        if constexpr (WithNanosecond) {
604
            if (!preserve_nanosecond) {
605
                // Keep the established %f behavior by rounding the complete instant, including
606
                // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000.
607
                constexpr int32_t MICROS_PER_SECOND = 1000000;
608
                const int32_t rounded_microseconds =
609
                        (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) /
610
                        TimeStampNsValue::NANOS_PER_MICROSECOND;
611
                epoch_second += rounded_microseconds / MICROS_PER_SECOND;
612
                nanosecond = rounded_microseconds % MICROS_PER_SECOND *
613
                             TimeStampNsValue::NANOS_PER_MICROSECOND;
614
            }
615
        }
616
4
        DateV2Value<DateTimeV2ValueType> dt;
617
4
        dt.from_unixtime(epoch_second, nanosecond, time_zone, 6);
618
4
        return dt;
619
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE18get_datetime_valueERKlS3_RKN4cctz9time_zoneEb
Line
Count
Source
600
4
                                                               bool preserve_nanosecond) {
601
4
        auto epoch_second = static_cast<int64_t>(interger);
602
4
        int32_t nanosecond = get_nanosecond(fraction);
603
        if constexpr (WithNanosecond) {
604
            if (!preserve_nanosecond) {
605
                // Keep the established %f behavior by rounding the complete instant, including
606
                // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000.
607
                constexpr int32_t MICROS_PER_SECOND = 1000000;
608
                const int32_t rounded_microseconds =
609
                        (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) /
610
                        TimeStampNsValue::NANOS_PER_MICROSECOND;
611
                epoch_second += rounded_microseconds / MICROS_PER_SECOND;
612
                nanosecond = rounded_microseconds % MICROS_PER_SECOND *
613
                             TimeStampNsValue::NANOS_PER_MICROSECOND;
614
            }
615
        }
616
4
        DateV2Value<DateTimeV2ValueType> dt;
617
4
        dt.from_unixtime(epoch_second, nanosecond, time_zone, 6);
618
4
        return dt;
619
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE18get_datetime_valueERKnS3_RKN4cctz9time_zoneEb
Line
Count
Source
600
14
                                                               bool preserve_nanosecond) {
601
14
        auto epoch_second = static_cast<int64_t>(interger);
602
14
        int32_t nanosecond = get_nanosecond(fraction);
603
14
        if constexpr (WithNanosecond) {
604
14
            if (!preserve_nanosecond) {
605
                // Keep the established %f behavior by rounding the complete instant, including
606
                // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000.
607
10
                constexpr int32_t MICROS_PER_SECOND = 1000000;
608
10
                const int32_t rounded_microseconds =
609
10
                        (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) /
610
10
                        TimeStampNsValue::NANOS_PER_MICROSECOND;
611
10
                epoch_second += rounded_microseconds / MICROS_PER_SECOND;
612
10
                nanosecond = rounded_microseconds % MICROS_PER_SECOND *
613
10
                             TimeStampNsValue::NANOS_PER_MICROSECOND;
614
10
            }
615
14
        }
616
14
        DateV2Value<DateTimeV2ValueType> dt;
617
14
        dt.from_unixtime(epoch_second, nanosecond, time_zone, 6);
618
14
        return dt;
619
14
    }
620
621
    // return true if null(result is invalid)
622
    template <typename Impl>
623
    static bool execute_decimal(const ArgType& interger, const ArgType& fraction, StringRef format,
624
                                ColumnString::Chars& res_data, size_t& offset,
625
26
                                const cctz::time_zone& time_zone) {
626
26
        if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] {
627
4
            return true;
628
4
        }
629
22
        int64_t fraction_adjustment = 0;
630
22
        if (fraction > 0) {
631
22
            fraction_adjustment = 1;
632
22
        } else if (fraction < 0) {
633
0
            fraction_adjustment = -1;
634
0
        }
635
22
        if (!check_valid(interger + fraction_adjustment)) [[unlikely]] {
636
0
            return true;
637
0
        }
638
22
        const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n');
639
22
        DateV2Value<DateTimeV2ValueType> dt =
640
22
                get_datetime_value(interger, fraction, time_zone, preserve_nanosecond);
641
22
        if (!dt.is_valid_date()) [[unlikely]] {
642
0
            return true;
643
0
        }
644
22
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
645
10
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
646
10
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
647
10
                                                  100 + SAFE_FORMAT_STRING_MARGIN,
648
10
                                                  get_nanosecond(fraction))) {
649
0
                return true;
650
0
            }
651
652
10
            auto len = strlen(buf);
653
10
            res_data.insert(buf, buf + len);
654
10
            offset += len;
655
12
        } else {
656
            // No buffer is needed here because these specially optimized formats have fixed lengths,
657
            // and sufficient memory has already been reserved.
658
12
            auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str(
659
12
                    dt, (char*)res_data.data() + offset);
660
12
            offset += len;
661
12
        }
662
0
        return false;
663
22
    }
_ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE15execute_decimalINS_16time_format_type30yyyy_MM_dd_HH_mm_ss_SSSSSSImplEEEbRKlS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
625
4
                                const cctz::time_zone& time_zone) {
626
4
        if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] {
627
0
            return true;
628
0
        }
629
4
        int64_t fraction_adjustment = 0;
630
4
        if (fraction > 0) {
631
4
            fraction_adjustment = 1;
632
4
        } else if (fraction < 0) {
633
0
            fraction_adjustment = -1;
634
0
        }
635
4
        if (!check_valid(interger + fraction_adjustment)) [[unlikely]] {
636
0
            return true;
637
0
        }
638
4
        const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n');
639
4
        DateV2Value<DateTimeV2ValueType> dt =
640
4
                get_datetime_value(interger, fraction, time_zone, preserve_nanosecond);
641
4
        if (!dt.is_valid_date()) [[unlikely]] {
642
0
            return true;
643
0
        }
644
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
645
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
646
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
647
                                                  100 + SAFE_FORMAT_STRING_MARGIN,
648
                                                  get_nanosecond(fraction))) {
649
                return true;
650
            }
651
652
            auto len = strlen(buf);
653
            res_data.insert(buf, buf + len);
654
            offset += len;
655
4
        } else {
656
            // No buffer is needed here because these specially optimized formats have fixed lengths,
657
            // and sufficient memory has already been reserved.
658
4
            auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str(
659
4
                    dt, (char*)res_data.data() + offset);
660
4
            offset += len;
661
4
        }
662
4
        return false;
663
4
    }
Unexecuted instantiation: _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE15execute_decimalINS_16time_format_type15UserDefinedImplEEEbRKlS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Unexecuted instantiation: _ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE15execute_decimalINS_16time_format_type30yyyy_MM_dd_HH_mm_ss_SSSSSSImplEEEbRKlS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE15execute_decimalINS_16time_format_type15UserDefinedImplEEEbRKlS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
625
6
                                const cctz::time_zone& time_zone) {
626
6
        if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] {
627
2
            return true;
628
2
        }
629
4
        int64_t fraction_adjustment = 0;
630
4
        if (fraction > 0) {
631
4
            fraction_adjustment = 1;
632
4
        } else if (fraction < 0) {
633
0
            fraction_adjustment = -1;
634
0
        }
635
4
        if (!check_valid(interger + fraction_adjustment)) [[unlikely]] {
636
0
            return true;
637
0
        }
638
4
        const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n');
639
4
        DateV2Value<DateTimeV2ValueType> dt =
640
4
                get_datetime_value(interger, fraction, time_zone, preserve_nanosecond);
641
4
        if (!dt.is_valid_date()) [[unlikely]] {
642
0
            return true;
643
0
        }
644
4
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
645
4
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
646
4
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
647
4
                                                  100 + SAFE_FORMAT_STRING_MARGIN,
648
4
                                                  get_nanosecond(fraction))) {
649
0
                return true;
650
0
            }
651
652
4
            auto len = strlen(buf);
653
4
            res_data.insert(buf, buf + len);
654
4
            offset += len;
655
        } else {
656
            // No buffer is needed here because these specially optimized formats have fixed lengths,
657
            // and sufficient memory has already been reserved.
658
            auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str(
659
                    dt, (char*)res_data.data() + offset);
660
            offset += len;
661
        }
662
0
        return false;
663
4
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE15execute_decimalINS_16time_format_type30yyyy_MM_dd_HH_mm_ss_SSSSSSImplEEEbRKnS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
625
8
                                const cctz::time_zone& time_zone) {
626
8
        if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] {
627
0
            return true;
628
0
        }
629
8
        int64_t fraction_adjustment = 0;
630
8
        if (fraction > 0) {
631
8
            fraction_adjustment = 1;
632
8
        } else if (fraction < 0) {
633
0
            fraction_adjustment = -1;
634
0
        }
635
8
        if (!check_valid(interger + fraction_adjustment)) [[unlikely]] {
636
0
            return true;
637
0
        }
638
8
        const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n');
639
8
        DateV2Value<DateTimeV2ValueType> dt =
640
8
                get_datetime_value(interger, fraction, time_zone, preserve_nanosecond);
641
8
        if (!dt.is_valid_date()) [[unlikely]] {
642
0
            return true;
643
0
        }
644
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
645
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
646
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
647
                                                  100 + SAFE_FORMAT_STRING_MARGIN,
648
                                                  get_nanosecond(fraction))) {
649
                return true;
650
            }
651
652
            auto len = strlen(buf);
653
            res_data.insert(buf, buf + len);
654
            offset += len;
655
8
        } else {
656
            // No buffer is needed here because these specially optimized formats have fixed lengths,
657
            // and sufficient memory has already been reserved.
658
8
            auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str(
659
8
                    dt, (char*)res_data.data() + offset);
660
8
            offset += len;
661
8
        }
662
8
        return false;
663
8
    }
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE15execute_decimalINS_16time_format_type15UserDefinedImplEEEbRKnS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE
Line
Count
Source
625
8
                                const cctz::time_zone& time_zone) {
626
8
        if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] {
627
2
            return true;
628
2
        }
629
6
        int64_t fraction_adjustment = 0;
630
6
        if (fraction > 0) {
631
6
            fraction_adjustment = 1;
632
6
        } else if (fraction < 0) {
633
0
            fraction_adjustment = -1;
634
0
        }
635
6
        if (!check_valid(interger + fraction_adjustment)) [[unlikely]] {
636
0
            return true;
637
0
        }
638
6
        const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n');
639
6
        DateV2Value<DateTimeV2ValueType> dt =
640
6
                get_datetime_value(interger, fraction, time_zone, preserve_nanosecond);
641
6
        if (!dt.is_valid_date()) [[unlikely]] {
642
0
            return true;
643
0
        }
644
6
        if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) {
645
6
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
646
6
            if (!dt.to_format_string_conservative(format.data, format.size, buf,
647
6
                                                  100 + SAFE_FORMAT_STRING_MARGIN,
648
6
                                                  get_nanosecond(fraction))) {
649
0
                return true;
650
0
            }
651
652
6
            auto len = strlen(buf);
653
6
            res_data.insert(buf, buf + len);
654
6
            offset += len;
655
        } else {
656
            // No buffer is needed here because these specially optimized formats have fixed lengths,
657
            // and sufficient memory has already been reserved.
658
            auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str(
659
                    dt, (char*)res_data.data() + offset);
660
            offset += len;
661
        }
662
0
        return false;
663
6
    }
664
};
665
666
// Base template for optimized time field(HOUR, MINUTE, SECOND, MS) extraction from Unix timestamp
667
// Uses lookup_offset to avoid expensive civil_second construction
668
template <typename Impl>
669
class FunctionTimeFieldFromUnixtime : public IFunction {
670
public:
671
    static constexpr auto name = Impl::name;
672
16
    static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE6createEv
Line
Count
Source
672
4
    static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE6createEv
Line
Count
Source
672
4
    static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE6createEv
Line
Count
Source
672
4
    static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE6createEv
Line
Count
Source
672
4
    static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }
673
674
8
    String get_name() const override { return name; }
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE8get_nameB5cxx11Ev
Line
Count
Source
674
2
    String get_name() const override { return name; }
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE8get_nameB5cxx11Ev
Line
Count
Source
674
2
    String get_name() const override { return name; }
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE8get_nameB5cxx11Ev
Line
Count
Source
674
2
    String get_name() const override { return name; }
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE8get_nameB5cxx11Ev
Line
Count
Source
674
2
    String get_name() const override { return name; }
675
676
0
    size_t get_number_of_arguments() const override { return 1; }
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE23get_number_of_argumentsEv
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE23get_number_of_argumentsEv
677
678
0
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
679
        // microsecond_from_unixtime returns Int32, others (hour/minute/second) return Int8
680
0
        if constexpr (Impl::ArgType == PrimitiveType::TYPE_DECIMAL64) {
681
0
            return make_nullable(std::make_shared<DataTypeInt32>());
682
0
        } else {
683
0
            return make_nullable(std::make_shared<DataTypeInt8>());
684
0
        }
685
0
    }
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
686
687
    // (UTC 9999-12-31 23:59:59) - 24 * 3600
688
    static const int64_t TIMESTAMP_VALID_MAX = 253402243199L;
689
690
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
691
0
                        uint32_t result, size_t input_rows_count) const override {
692
0
        using ArgColType = typename PrimitiveTypeTraits<Impl::ArgType>::ColumnType;
693
0
        using ResColType = std::conditional_t<Impl::ArgType == PrimitiveType::TYPE_DECIMAL64,
694
0
                                              ColumnInt32, ColumnInt8>;
695
0
        using ResItemType = typename ResColType::value_type;
696
0
        auto res = ResColType::create();
697
698
0
        const auto* ts_col =
699
0
                assert_cast<const ArgColType*>(block.get_by_position(arguments[0]).column.get());
700
0
        if constexpr (Impl::ArgType == PrimitiveType::TYPE_DECIMAL64) {
701
            // microsecond_from_unixtime only
702
0
            const auto scale = static_cast<int32_t>(ts_col->get_scale());
703
704
0
            for (int i = 0; i < input_rows_count; ++i) {
705
0
                const auto seconds = ts_col->get_intergral_part(i);
706
0
                const auto fraction = ts_col->get_fractional_part(i);
707
708
0
                if (seconds < 0 || seconds > TIMESTAMP_VALID_MAX) {
709
0
                    return Status::InvalidArgument(
710
0
                            "The input value of TimeFiled(from_unixtime()) must between 0 and "
711
0
                            "253402243199L");
712
0
                }
713
714
0
                ResItemType value = Impl::extract_field(fraction, scale);
715
0
                res->insert_value(value);
716
0
            }
717
0
        } else {
718
0
            auto ctz = context->state()->timezone_obj();
719
0
            for (int i = 0; i < input_rows_count; ++i) {
720
0
                auto date = ts_col->get_element(i);
721
722
0
                if (date < 0 || date > TIMESTAMP_VALID_MAX) {
723
0
                    return Status::InvalidArgument(
724
0
                            "The input value of TimeFiled(from_unixtime()) must between 0 and "
725
0
                            "253402243199L");
726
0
                }
727
728
0
                ResItemType value = Impl::extract_field(date, ctz);
729
0
                res->insert_value(value);
730
0
            }
731
0
        }
732
0
        block.replace_by_position(result, std::move(res));
733
0
        return Status::OK();
734
0
    }
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Unexecuted instantiation: _ZNK5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
735
};
736
737
struct HourFromUnixtimeImpl {
738
    static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT;
739
    static constexpr auto name = "hour_from_unixtime";
740
741
0
    static int8_t extract_field(int64_t local_time, const cctz::time_zone& ctz) {
742
0
        static const auto epoch = std::chrono::time_point_cast<cctz::sys_seconds>(
743
0
                std::chrono::system_clock::from_time_t(0));
744
0
        cctz::time_point<cctz::sys_seconds> t = epoch + cctz::seconds(local_time);
745
0
        int offset = ctz.lookup_offset(t).offset;
746
0
        local_time += offset;
747
748
0
        static const libdivide::divider<int64_t> fast_div_3600(3600);
749
0
        static const libdivide::divider<int64_t> fast_div_86400(86400);
750
751
0
        int64_t remainder;
752
0
        if (LIKELY(local_time >= 0)) {
753
0
            remainder = local_time - local_time / fast_div_86400 * 86400;
754
0
        } else {
755
0
            remainder = local_time % 86400;
756
0
            if (remainder < 0) {
757
0
                remainder += 86400;
758
0
            }
759
0
        }
760
0
        return static_cast<int8_t>(remainder / fast_div_3600);
761
0
    }
762
};
763
764
struct MinuteFromUnixtimeImpl {
765
    static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT;
766
    static constexpr auto name = "minute_from_unixtime";
767
768
0
    static int8_t extract_field(int64_t local_time, const cctz::time_zone& /*ctz*/) {
769
0
        static const libdivide::divider<int64_t> fast_div_60(60);
770
0
        static const libdivide::divider<int64_t> fast_div_3600(3600);
771
772
0
        local_time = local_time - local_time / fast_div_3600 * 3600;
773
774
0
        return static_cast<int8_t>(local_time / fast_div_60);
775
0
    }
776
};
777
778
struct SecondFromUnixtimeImpl {
779
    static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT;
780
    static constexpr auto name = "second_from_unixtime";
781
782
0
    static int8_t extract_field(int64_t local_time, const cctz::time_zone& /*ctz*/) {
783
0
        return static_cast<int8_t>(local_time % 60);
784
0
    }
785
};
786
787
struct MicrosecondFromUnixtimeImpl {
788
    static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_DECIMAL64;
789
    static constexpr auto name = "microsecond_from_unixtime";
790
791
0
    static int32_t extract_field(int64_t fraction, int scale) {
792
0
        if (scale < 6) {
793
0
            fraction *= common::exp10_i64(6 - scale);
794
0
        }
795
0
        return static_cast<int32_t>(fraction);
796
0
    }
797
};
798
799
template <PrimitiveType ArgPType>
800
class FunctionTimeFormat : public IFunction {
801
public:
802
    using ArgColType = typename PrimitiveTypeTraits<ArgPType>::ColumnType;
803
    using ArgCppType = typename PrimitiveTypeTraits<ArgPType>::CppType;
804
805
    static constexpr auto name = "time_format";
806
8
    String get_name() const override { return name; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE8get_nameB5cxx11Ev
Line
Count
Source
806
2
    String get_name() const override { return name; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE8get_nameB5cxx11Ev
Line
Count
Source
806
2
    String get_name() const override { return name; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE8get_nameB5cxx11Ev
Line
Count
Source
806
2
    String get_name() const override { return name; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE8get_nameB5cxx11Ev
Line
Count
Source
806
2
    String get_name() const override { return name; }
807
26
    static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE6createEv
Line
Count
Source
807
4
    static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE6createEv
Line
Count
Source
807
6
    static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE6createEv
Line
Count
Source
807
6
    static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE6createEv
Line
Count
Source
807
10
    static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }
808
8
    DataTypes get_variadic_argument_types_impl() const override {
809
8
        return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(),
810
8
                std::make_shared<DataTypeString>()};
811
8
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE32get_variadic_argument_types_implEv
Line
Count
Source
808
2
    DataTypes get_variadic_argument_types_impl() const override {
809
2
        return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(),
810
2
                std::make_shared<DataTypeString>()};
811
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE32get_variadic_argument_types_implEv
Line
Count
Source
808
2
    DataTypes get_variadic_argument_types_impl() const override {
809
2
        return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(),
810
2
                std::make_shared<DataTypeString>()};
811
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE32get_variadic_argument_types_implEv
Line
Count
Source
808
2
    DataTypes get_variadic_argument_types_impl() const override {
809
2
        return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(),
810
2
                std::make_shared<DataTypeString>()};
811
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE32get_variadic_argument_types_implEv
Line
Count
Source
808
2
    DataTypes get_variadic_argument_types_impl() const override {
809
2
        return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(),
810
2
                std::make_shared<DataTypeString>()};
811
2
    }
812
10
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
813
10
        return make_nullable(std::make_shared<DataTypeString>());
814
10
    }
Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Line
Count
Source
812
2
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
813
2
        return make_nullable(std::make_shared<DataTypeString>());
814
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Line
Count
Source
812
2
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
813
2
        return make_nullable(std::make_shared<DataTypeString>());
814
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE
Line
Count
Source
812
6
    DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override {
813
6
        return make_nullable(std::make_shared<DataTypeString>());
814
6
    }
815
10
    size_t get_number_of_arguments() const override { return 2; }
Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE23get_number_of_argumentsEv
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE23get_number_of_argumentsEv
Line
Count
Source
815
2
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE23get_number_of_argumentsEv
Line
Count
Source
815
2
    size_t get_number_of_arguments() const override { return 2; }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE23get_number_of_argumentsEv
Line
Count
Source
815
6
    size_t get_number_of_arguments() const override { return 2; }
816
817
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
818
10
                        uint32_t result, size_t input_rows_count) const override {
819
10
        auto res_col = ColumnString::create();
820
10
        ColumnString::Chars& res_chars = res_col->get_chars();
821
10
        ColumnString::Offsets& res_offsets = res_col->get_offsets();
822
823
10
        auto null_map = ColumnUInt8::create();
824
10
        auto& null_map_data = null_map->get_data();
825
10
        null_map_data.resize_fill(input_rows_count, 0);
826
827
10
        res_offsets.reserve(input_rows_count);
828
829
10
        ColumnPtr arg_col[2];
830
10
        bool is_const[2];
831
30
        for (size_t i = 0; i < 2; ++i) {
832
20
            const ColumnPtr& col = block.get_by_position(arguments[i]).column;
833
20
            std::tie(arg_col[i], is_const[i]) = unpack_if_const(col);
834
20
        }
835
836
10
        const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get());
837
10
        const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get());
838
20
        for (size_t i = 0; i < input_rows_count; ++i) {
839
10
            const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0]));
840
10
            StringRef format = format_col->get_data_at(index_check_const(i, is_const[1]));
841
10
            TimeValue::TimeType time = get_time_value(datetime_val);
842
843
10
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
844
10
            const bool formatted = [&]() {
845
10
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
2
                    return TimeValue::to_format_string_conservative(
847
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
2
                            datetime_val.nanosecond());
849
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
8
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
8
                    return TimeValue::to_format_string_conservative(
852
8
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
8
                            TimeValue::microsecond(time) * 1000);
854
8
                } else {
855
0
                    return TimeValue::to_format_string_conservative(
856
0
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
0
                }
858
10
            }();
Unexecuted instantiation: _ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv
_ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv
Line
Count
Source
844
2
            const bool formatted = [&]() {
845
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
                    return TimeValue::to_format_string_conservative(
847
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
                            datetime_val.nanosecond());
849
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
2
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
2
                    return TimeValue::to_format_string_conservative(
852
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
2
                            TimeValue::microsecond(time) * 1000);
854
                } else {
855
                    return TimeValue::to_format_string_conservative(
856
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
                }
858
2
            }();
_ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv
Line
Count
Source
844
2
            const bool formatted = [&]() {
845
2
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
2
                    return TimeValue::to_format_string_conservative(
847
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
2
                            datetime_val.nanosecond());
849
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
                    return TimeValue::to_format_string_conservative(
852
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
                            TimeValue::microsecond(time) * 1000);
854
                } else {
855
                    return TimeValue::to_format_string_conservative(
856
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
                }
858
2
            }();
_ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv
Line
Count
Source
844
6
            const bool formatted = [&]() {
845
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
                    return TimeValue::to_format_string_conservative(
847
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
                            datetime_val.nanosecond());
849
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
6
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
6
                    return TimeValue::to_format_string_conservative(
852
6
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
6
                            TimeValue::microsecond(time) * 1000);
854
                } else {
855
                    return TimeValue::to_format_string_conservative(
856
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
                }
858
6
            }();
859
10
            if (!formatted) {
860
0
                null_map_data[i] = 1;
861
0
                res_offsets.push_back(res_chars.size());
862
0
                continue;
863
0
            }
864
10
            res_chars.insert(buf, buf + strlen(buf));
865
10
            res_offsets.push_back(res_chars.size());
866
10
        }
867
10
        block.replace_by_position(result,
868
10
                                  ColumnNullable::create(std::move(res_col), std::move(null_map)));
869
10
        return Status::OK();
870
10
    }
Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
818
2
                        uint32_t result, size_t input_rows_count) const override {
819
2
        auto res_col = ColumnString::create();
820
2
        ColumnString::Chars& res_chars = res_col->get_chars();
821
2
        ColumnString::Offsets& res_offsets = res_col->get_offsets();
822
823
2
        auto null_map = ColumnUInt8::create();
824
2
        auto& null_map_data = null_map->get_data();
825
2
        null_map_data.resize_fill(input_rows_count, 0);
826
827
2
        res_offsets.reserve(input_rows_count);
828
829
2
        ColumnPtr arg_col[2];
830
2
        bool is_const[2];
831
6
        for (size_t i = 0; i < 2; ++i) {
832
4
            const ColumnPtr& col = block.get_by_position(arguments[i]).column;
833
4
            std::tie(arg_col[i], is_const[i]) = unpack_if_const(col);
834
4
        }
835
836
2
        const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get());
837
2
        const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get());
838
4
        for (size_t i = 0; i < input_rows_count; ++i) {
839
2
            const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0]));
840
2
            StringRef format = format_col->get_data_at(index_check_const(i, is_const[1]));
841
2
            TimeValue::TimeType time = get_time_value(datetime_val);
842
843
2
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
844
2
            const bool formatted = [&]() {
845
2
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
2
                    return TimeValue::to_format_string_conservative(
847
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
2
                            datetime_val.nanosecond());
849
2
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
2
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
2
                    return TimeValue::to_format_string_conservative(
852
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
2
                            TimeValue::microsecond(time) * 1000);
854
2
                } else {
855
2
                    return TimeValue::to_format_string_conservative(
856
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
2
                }
858
2
            }();
859
2
            if (!formatted) {
860
0
                null_map_data[i] = 1;
861
0
                res_offsets.push_back(res_chars.size());
862
0
                continue;
863
0
            }
864
2
            res_chars.insert(buf, buf + strlen(buf));
865
2
            res_offsets.push_back(res_chars.size());
866
2
        }
867
2
        block.replace_by_position(result,
868
2
                                  ColumnNullable::create(std::move(res_col), std::move(null_map)));
869
2
        return Status::OK();
870
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
818
2
                        uint32_t result, size_t input_rows_count) const override {
819
2
        auto res_col = ColumnString::create();
820
2
        ColumnString::Chars& res_chars = res_col->get_chars();
821
2
        ColumnString::Offsets& res_offsets = res_col->get_offsets();
822
823
2
        auto null_map = ColumnUInt8::create();
824
2
        auto& null_map_data = null_map->get_data();
825
2
        null_map_data.resize_fill(input_rows_count, 0);
826
827
2
        res_offsets.reserve(input_rows_count);
828
829
2
        ColumnPtr arg_col[2];
830
2
        bool is_const[2];
831
6
        for (size_t i = 0; i < 2; ++i) {
832
4
            const ColumnPtr& col = block.get_by_position(arguments[i]).column;
833
4
            std::tie(arg_col[i], is_const[i]) = unpack_if_const(col);
834
4
        }
835
836
2
        const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get());
837
2
        const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get());
838
4
        for (size_t i = 0; i < input_rows_count; ++i) {
839
2
            const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0]));
840
2
            StringRef format = format_col->get_data_at(index_check_const(i, is_const[1]));
841
2
            TimeValue::TimeType time = get_time_value(datetime_val);
842
843
2
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
844
2
            const bool formatted = [&]() {
845
2
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
2
                    return TimeValue::to_format_string_conservative(
847
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
2
                            datetime_val.nanosecond());
849
2
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
2
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
2
                    return TimeValue::to_format_string_conservative(
852
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
2
                            TimeValue::microsecond(time) * 1000);
854
2
                } else {
855
2
                    return TimeValue::to_format_string_conservative(
856
2
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
2
                }
858
2
            }();
859
2
            if (!formatted) {
860
0
                null_map_data[i] = 1;
861
0
                res_offsets.push_back(res_chars.size());
862
0
                continue;
863
0
            }
864
2
            res_chars.insert(buf, buf + strlen(buf));
865
2
            res_offsets.push_back(res_chars.size());
866
2
        }
867
2
        block.replace_by_position(result,
868
2
                                  ColumnNullable::create(std::move(res_col), std::move(null_map)));
869
2
        return Status::OK();
870
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm
Line
Count
Source
818
6
                        uint32_t result, size_t input_rows_count) const override {
819
6
        auto res_col = ColumnString::create();
820
6
        ColumnString::Chars& res_chars = res_col->get_chars();
821
6
        ColumnString::Offsets& res_offsets = res_col->get_offsets();
822
823
6
        auto null_map = ColumnUInt8::create();
824
6
        auto& null_map_data = null_map->get_data();
825
6
        null_map_data.resize_fill(input_rows_count, 0);
826
827
6
        res_offsets.reserve(input_rows_count);
828
829
6
        ColumnPtr arg_col[2];
830
6
        bool is_const[2];
831
18
        for (size_t i = 0; i < 2; ++i) {
832
12
            const ColumnPtr& col = block.get_by_position(arguments[i]).column;
833
12
            std::tie(arg_col[i], is_const[i]) = unpack_if_const(col);
834
12
        }
835
836
6
        const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get());
837
6
        const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get());
838
12
        for (size_t i = 0; i < input_rows_count; ++i) {
839
6
            const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0]));
840
6
            StringRef format = format_col->get_data_at(index_check_const(i, is_const[1]));
841
6
            TimeValue::TimeType time = get_time_value(datetime_val);
842
843
6
            char buf[100 + SAFE_FORMAT_STRING_MARGIN];
844
6
            const bool formatted = [&]() {
845
6
                if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
846
6
                    return TimeValue::to_format_string_conservative(
847
6
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
848
6
                            datetime_val.nanosecond());
849
6
                } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 ||
850
6
                                     ArgPType == PrimitiveType::TYPE_TIMEV2) {
851
6
                    return TimeValue::to_format_string_conservative(
852
6
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time,
853
6
                            TimeValue::microsecond(time) * 1000);
854
6
                } else {
855
6
                    return TimeValue::to_format_string_conservative(
856
6
                            format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time);
857
6
                }
858
6
            }();
859
6
            if (!formatted) {
860
0
                null_map_data[i] = 1;
861
0
                res_offsets.push_back(res_chars.size());
862
0
                continue;
863
0
            }
864
6
            res_chars.insert(buf, buf + strlen(buf));
865
6
            res_offsets.push_back(res_chars.size());
866
6
        }
867
6
        block.replace_by_position(result,
868
6
                                  ColumnNullable::create(std::move(res_col), std::move(null_map)));
869
6
        return Status::OK();
870
6
    }
871
872
private:
873
10
    TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const {
874
10
        if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) {
875
6
            return static_cast<TimeValue::TimeType>(datetime_val);
876
6
        } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
877
2
            return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond());
878
2
        } else {
879
2
            return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(),
880
2
                                        datetime_val.second(), datetime_val.microsecond());
881
2
        }
882
10
    }
Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE14get_time_valueERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE14get_time_valueERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE
Line
Count
Source
873
2
    TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const {
874
        if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) {
875
            return static_cast<TimeValue::TimeType>(datetime_val);
876
        } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
877
            return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond());
878
2
        } else {
879
2
            return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(),
880
2
                                        datetime_val.second(), datetime_val.microsecond());
881
2
        }
882
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE14get_time_valueERKNS_16TimeStampNsValueE
Line
Count
Source
873
2
    TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const {
874
        if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) {
875
            return static_cast<TimeValue::TimeType>(datetime_val);
876
2
        } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
877
2
            return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond());
878
        } else {
879
            return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(),
880
                                        datetime_val.second(), datetime_val.microsecond());
881
        }
882
2
    }
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE14get_time_valueERKd
Line
Count
Source
873
6
    TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const {
874
6
        if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) {
875
6
            return static_cast<TimeValue::TimeType>(datetime_val);
876
        } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) {
877
            return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond());
878
        } else {
879
            return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(),
880
                                        datetime_val.second(), datetime_val.microsecond());
881
        }
882
6
    }
883
};
884
885
} // namespace doris
886
887
#if defined(__GNUC__) && (__GNUC__ >= 15)
888
#pragma GCC diagnostic pop
889
#endif