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 | 6.23k | static inline auto execute(const CppType& date_time_value) { \ |
70 | 6.23k | return date_time_value.FUNCTION; \ |
71 | 6.23k | } \ _ZN5doris12ToSecondImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
_ZN5doris9ToDayImplILNS_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 | } \ |
_ZN5doris11ToMonthImplILNS_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 | } \ |
_ZN5doris10ToYearImplILNS_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 | } \ |
_ZN5doris16ToYearOfWeekImplILNS_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 | } \ |
_ZN5doris13ToQuarterImplILNS_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 | } \ |
_ZN5doris10ToDaysImplILNS_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 | } \ |
Unexecuted instantiation: _ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE _ZN5doris12ToSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 5 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 5 | return date_time_value.FUNCTION; \ | 71 | 5 | } \ |
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 5 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 5 | return date_time_value.FUNCTION; \ | 71 | 5 | } \ |
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 6.14k | static inline auto execute(const CppType& date_time_value) { \ | 70 | 6.14k | return date_time_value.FUNCTION; \ | 71 | 6.14k | } \ |
_ZN5doris9ToDayImplILNS_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 | } \ |
_ZN5doris11ToMonthImplILNS_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 | } \ |
_ZN5doris10ToYearImplILNS_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 | } \ |
_ZN5doris13ToQuarterImplILNS_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 | } \ |
Unexecuted instantiation: _ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Unexecuted instantiation: _ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE Unexecuted instantiation: _ZN5doris12ToSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE _ZN5doris10ToDaysImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE Line | Count | Source | 69 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
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 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE 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: _ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE Unexecuted instantiation: _ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE _ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 1 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 1 | return date_time_value.FUNCTION; \ | 71 | 1 | } \ |
_ZN5doris14DayOfMonthImplILNS_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 | } \ |
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 1 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 1 | return date_time_value.FUNCTION; \ | 71 | 1 | } \ |
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 69 | 1 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 1 | return date_time_value.FUNCTION; \ | 71 | 1 | } \ |
_ZN5doris11WeekDayImplILNS_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_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 3 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 3 | return date_time_value.FUNCTION; \ | 71 | 3 | } \ |
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 2 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 2 | return date_time_value.FUNCTION; \ | 71 | 2 | } \ |
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 69 | 5 | static inline auto execute(const CppType& date_time_value) { \ | 70 | 5 | return date_time_value.FUNCTION; \ | 71 | 5 | } \ |
_ZN5doris14DayOfMonthImplILNS_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 | } \ |
_ZN5doris11WeekDayImplILNS_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 | } \ |
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 |
72 | | \ |
73 | 44 | static DataTypes get_variadic_argument_types() { \ |
74 | 44 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ |
75 | 44 | } \ _ZN5doris12ToSecondImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris17ToMicroSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris12ToSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToDaysImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris12ToMinuteImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToHourImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris9ToDayImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11ToMonthImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris10ToYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris16ToYearOfWeekImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13ToQuarterImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13ToSecondsImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14WeekOfYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfYearImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris13DayOfWeekImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris14DayOfMonthImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
_ZN5doris11WeekDayImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 73 | 1 | static DataTypes get_variadic_argument_types() { \ | 74 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 75 | 1 | } \ |
|
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 | 31 | static inline auto execute(const CppType& t) { |
88 | 31 | const auto& date_time_value = t; |
89 | 31 | int year = date_time_value.year(); |
90 | 31 | return (year - 1) / 100 + 1; |
91 | 31 | } _ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 87 | 4 | static inline auto execute(const CppType& t) { | 88 | 4 | const auto& date_time_value = t; | 89 | 4 | int year = date_time_value.year(); | 90 | 4 | return (year - 1) / 100 + 1; | 91 | 4 | } |
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 87 | 27 | static inline auto execute(const CppType& t) { | 88 | 27 | const auto& date_time_value = t; | 89 | 27 | int year = date_time_value.year(); | 90 | 27 | return (year - 1) / 100 + 1; | 91 | 27 | } |
Unexecuted instantiation: _ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE |
92 | | |
93 | 3 | static DataTypes get_variadic_argument_types() { |
94 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
95 | 3 | } _ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 93 | 1 | static DataTypes get_variadic_argument_types() { | 94 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 95 | 1 | } |
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 93 | 1 | static DataTypes get_variadic_argument_types() { | 94 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 95 | 1 | } |
_ZN5doris13ToCenturyImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 93 | 1 | static DataTypes get_variadic_argument_types() { | 94 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 95 | 1 | } |
|
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 | 11 | static inline auto execute(const CppType& date_time_value) { |
112 | 11 | if constexpr (PType == TYPE_TIMESTAMP_NS) { |
113 | 4 | return date_time_value.nanosecond(); |
114 | 7 | } else { |
115 | 7 | return static_cast<uint32_t>(date_time_value.microsecond()) * |
116 | 7 | static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND); |
117 | 7 | } |
118 | 11 | } _ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 111 | 3 | static inline auto execute(const CppType& date_time_value) { | 112 | | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 113 | | return date_time_value.nanosecond(); | 114 | 3 | } else { | 115 | 3 | return static_cast<uint32_t>(date_time_value.microsecond()) * | 116 | 3 | static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND); | 117 | 3 | } | 118 | 3 | } |
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 111 | 4 | static inline auto execute(const CppType& date_time_value) { | 112 | | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 113 | | return date_time_value.nanosecond(); | 114 | 4 | } else { | 115 | 4 | return static_cast<uint32_t>(date_time_value.microsecond()) * | 116 | 4 | static_cast<uint32_t>(TimeStampNsValue::NANOS_PER_MICROSECOND); | 117 | 4 | } | 118 | 4 | } |
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE Line | Count | Source | 111 | 4 | static inline auto execute(const CppType& date_time_value) { | 112 | 4 | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 113 | 4 | 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 | 4 | } |
|
119 | | |
120 | 3 | static DataTypes get_variadic_argument_types() { |
121 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
122 | 3 | } _ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 1 | static DataTypes get_variadic_argument_types() { | 121 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 122 | 1 | } |
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 1 | static DataTypes get_variadic_argument_types() { | 121 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 122 | 1 | } |
_ZN5doris16ToNanoSecondImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 120 | 1 | static DataTypes get_variadic_argument_types() { | 121 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 122 | 1 | } |
|
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 | 12 | static inline auto execute(const ArgType& t) { \ |
143 | 12 | const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \ |
144 | 12 | return date_time_value.FUNCTION; \ |
145 | 12 | } \ _ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 142 | 2 | static inline auto execute(const ArgType& t) { \ | 143 | 2 | const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \ | 144 | 2 | return date_time_value.FUNCTION; \ | 145 | 2 | } \ |
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE 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 | } \ |
Unexecuted instantiation: _ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE _ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 142 | 2 | static inline auto execute(const ArgType& t) { \ | 143 | 2 | const auto& date_time_value = (typename PrimitiveTypeTraits<PType>::CppType&)(t); \ | 144 | 2 | return date_time_value.FUNCTION; \ | 145 | 2 | } \ |
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE 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 | } \ |
Unexecuted instantiation: _ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE |
146 | | \ |
147 | 6 | static DataTypes get_variadic_argument_types() { \ |
148 | 6 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ |
149 | 6 | } \ _ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
_ZN5doris16ToWeekOneArgImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
_ZN5doris20ToYearWeekOneArgImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 147 | 1 | static DataTypes get_variadic_argument_types() { \ | 148 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; \ | 149 | 1 | } \ |
|
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 | 8 | static auto execute(const DateType& t) { |
162 | 8 | if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) { |
163 | 2 | return t; |
164 | | } else if constexpr (std::is_same_v<DateType, VecDateTimeValue>) { |
165 | | t.cast_to_date(); |
166 | | return t; |
167 | 3 | } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) { |
168 | 3 | return t.to_date(); |
169 | 3 | } else { |
170 | 3 | return binary_cast<UInt32, DateV2Value<DateV2ValueType>>( |
171 | 3 | (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH)); |
172 | 3 | } |
173 | 8 | } _ZN5doris10ToDateImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE Line | Count | Source | 161 | 2 | static auto execute(const DateType& t) { | 162 | 2 | if constexpr (std::is_same_v<DateType, DateV2Value<DateV2ValueType>>) { | 163 | 2 | 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 | 2 | } |
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 161 | 3 | 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 | 3 | } else { | 170 | 3 | return binary_cast<UInt32, DateV2Value<DateV2ValueType>>( | 171 | 3 | (UInt32)(t.to_date_int_val() >> TIME_PART_LENGTH)); | 172 | 3 | } | 173 | 3 | } |
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueE Line | Count | Source | 161 | 3 | 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 | 3 | } else if constexpr (std::is_same_v<DateType, TimeStampNsValue>) { | 168 | 3 | 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 | 3 | } |
|
174 | | |
175 | 6 | static DataTypes get_variadic_argument_types() { |
176 | 6 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
177 | 6 | } _ZN5doris10ToDateImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 175 | 2 | static DataTypes get_variadic_argument_types() { | 176 | 2 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 177 | 2 | } |
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 175 | 2 | static DataTypes get_variadic_argument_types() { | 176 | 2 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 177 | 2 | } |
_ZN5doris10ToDateImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 175 | 2 | static DataTypes get_variadic_argument_types() { | 176 | 2 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 177 | 2 | } |
|
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 | 2 | static DataTypes get_variadic_argument_types() { |
195 | 2 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
196 | 2 | } _ZN5doris13TimeStampImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 194 | 1 | static DataTypes get_variadic_argument_types() { | 195 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 196 | 1 | } |
_ZN5doris13TimeStampImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 194 | 1 | static DataTypes get_variadic_argument_types() { | 195 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 196 | 1 | } |
|
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 | 3 | FunctionContext* /*context*/) { |
209 | 3 | DCHECK(day_names != nullptr); |
210 | 3 | const auto* day_name = dt.day_name_with_locale(day_names); |
211 | 3 | if (day_name != nullptr) { |
212 | 3 | auto len = strlen(day_name); |
213 | 3 | memcpy(&res_data[offset], day_name, len); |
214 | 3 | offset += len; |
215 | 3 | } |
216 | 3 | return offset; |
217 | 3 | } _ZN5doris11DayNameImplILNS_13PrimitiveTypeE25EE7executeERKNS_11DateV2ValueINS_15DateV2ValueTypeEEERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE Line | Count | Source | 208 | 1 | FunctionContext* /*context*/) { | 209 | 1 | DCHECK(day_names != nullptr); | 210 | 1 | const auto* day_name = dt.day_name_with_locale(day_names); | 211 | 1 | if (day_name != nullptr) { | 212 | 1 | auto len = strlen(day_name); | 213 | 1 | memcpy(&res_data[offset], day_name, len); | 214 | 1 | offset += len; | 215 | 1 | } | 216 | 1 | return offset; | 217 | 1 | } |
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE26EE7executeERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEERNS_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 | } |
Unexecuted instantiation: _ZN5doris11DayNameImplILNS_13PrimitiveTypeE43EE7executeERKNS_16TimeStampNsValueERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmPKPKcPNS_15FunctionContextE |
218 | | |
219 | 3 | static DataTypes get_variadic_argument_types() { |
220 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
221 | 3 | } _ZN5doris11DayNameImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 219 | 1 | static DataTypes get_variadic_argument_types() { | 220 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 221 | 1 | } |
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 219 | 1 | static DataTypes get_variadic_argument_types() { | 220 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 221 | 1 | } |
_ZN5doris11DayNameImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 219 | 1 | static DataTypes get_variadic_argument_types() { | 220 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 221 | 1 | } |
|
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 | 3 | static DataTypes get_variadic_argument_types() { |
258 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
259 | 3 | } _ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 257 | 1 | static DataTypes get_variadic_argument_types() { | 258 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 259 | 1 | } |
_ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 257 | 1 | static DataTypes get_variadic_argument_types() { | 258 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 259 | 1 | } |
_ZN5doris13ToIso8601ImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 257 | 1 | static DataTypes get_variadic_argument_types() { | 258 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 259 | 1 | } |
|
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 | | // A historical offset can contain seconds. |
269 | | static constexpr auto max_size = 35; |
270 | | |
271 | | static auto execute(const TimestampTzValue& tz_value, ColumnString::Chars& res_data, |
272 | | size_t& offset, const char* const* /*names_ptr*/, |
273 | 2 | FunctionContext* context) { |
274 | 2 | const int length = tz_value.to_buffer((char*)res_data.data() + offset, |
275 | 2 | context->state()->timezone_obj()); |
276 | 2 | res_data[offset + 10] = 'T'; |
277 | 2 | offset += length; |
278 | 2 | return offset; |
279 | 2 | } |
280 | | |
281 | 1 | static DataTypes get_variadic_argument_types() { |
282 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<TYPE_TIMESTAMPTZ>::DataType>()}; |
283 | 1 | } |
284 | | }; |
285 | | |
286 | | template <PrimitiveType PType> |
287 | | struct MonthNameImpl { |
288 | | static constexpr PrimitiveType OpArgType = PType; |
289 | | using ArgType = typename PrimitiveTypeTraits<PType>::CppType; |
290 | | static constexpr auto name = "monthname"; |
291 | | static constexpr auto max_size = MAX_MONTH_NAME_LEN; |
292 | | |
293 | | static auto execute(const typename PrimitiveTypeTraits<PType>::CppType& dt, |
294 | | ColumnString::Chars& res_data, size_t& offset, |
295 | 0 | const char* const* month_names, FunctionContext* /*context*/) { |
296 | 0 | DCHECK(month_names != nullptr); |
297 | 0 | const auto* month_name = dt.month_name_with_locale(month_names); |
298 | 0 | if (month_name != nullptr) { |
299 | 0 | auto len = strlen(month_name); |
300 | 0 | memcpy(&res_data[offset], month_name, len); |
301 | 0 | offset += len; |
302 | 0 | } |
303 | 0 | return offset; |
304 | 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 |
305 | | |
306 | 3 | static DataTypes get_variadic_argument_types() { |
307 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
308 | 3 | } _ZN5doris13MonthNameImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 306 | 1 | static DataTypes get_variadic_argument_types() { | 307 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 308 | 1 | } |
_ZN5doris13MonthNameImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 306 | 1 | static DataTypes get_variadic_argument_types() { | 307 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 308 | 1 | } |
_ZN5doris13MonthNameImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 306 | 1 | static DataTypes get_variadic_argument_types() { | 307 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 308 | 1 | } |
|
309 | | }; |
310 | | |
311 | | template <PrimitiveType PType, typename FormatImpl, const char* FuncName> |
312 | | struct DateTimeV2FormatImpl { |
313 | | static_assert(PType == TYPE_DATETIMEV2 || PType == TYPE_TIMESTAMP_NS); |
314 | | static constexpr PrimitiveType OpArgType = PType; |
315 | | using ArgType = typename PrimitiveTypeTraits<PType>::CppType; |
316 | | static constexpr auto name = FuncName; |
317 | | static constexpr auto max_size = FormatImpl::row_size; |
318 | | |
319 | | static auto execute(const ArgType& dt, ColumnString::Chars& res_data, size_t& offset, |
320 | 2 | const char* const* /*names_ptr*/, FunctionContext* /*context*/) { |
321 | 2 | auto* buf = reinterpret_cast<char*>(&res_data[offset]); |
322 | 2 | constexpr bool needs_civil_datetime = |
323 | 2 | std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> || |
324 | 2 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> || |
325 | 2 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> || |
326 | 2 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>; |
327 | | if constexpr (PType == TYPE_TIMESTAMP_NS && |
328 | 1 | std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) { |
329 | 1 | const auto civil_value = dt.to_date(); |
330 | 1 | offset += FormatImpl::date_to_str(civil_value, buf); |
331 | 1 | } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) { |
332 | 1 | const auto civil_value = dt.to_datetime(); |
333 | 1 | offset += FormatImpl::date_to_str(civil_value, buf); |
334 | 1 | } else { |
335 | 0 | offset += FormatImpl::date_to_str(dt, buf); |
336 | 0 | } |
337 | 2 | return offset; |
338 | 2 | } 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 | 320 | 1 | const char* const* /*names_ptr*/, FunctionContext* /*context*/) { | 321 | 1 | auto* buf = reinterpret_cast<char*>(&res_data[offset]); | 322 | 1 | constexpr bool needs_civil_datetime = | 323 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> || | 324 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> || | 325 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> || | 326 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>; | 327 | | if constexpr (PType == TYPE_TIMESTAMP_NS && | 328 | 1 | std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) { | 329 | 1 | const auto civil_value = dt.to_date(); | 330 | 1 | offset += FormatImpl::date_to_str(civil_value, buf); | 331 | | } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) { | 332 | | const auto civil_value = dt.to_datetime(); | 333 | | offset += FormatImpl::date_to_str(civil_value, buf); | 334 | | } else { | 335 | | offset += FormatImpl::date_to_str(dt, buf); | 336 | | } | 337 | 1 | return offset; | 338 | 1 | } |
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 | 320 | 1 | const char* const* /*names_ptr*/, FunctionContext* /*context*/) { | 321 | 1 | auto* buf = reinterpret_cast<char*>(&res_data[offset]); | 322 | 1 | constexpr bool needs_civil_datetime = | 323 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HHImpl> || | 324 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mmImpl> || | 325 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ssImpl> || | 326 | 1 | std::is_same_v<FormatImpl, time_format_type::dd_HH_mm_ss_SSSSSSImpl>; | 327 | | if constexpr (PType == TYPE_TIMESTAMP_NS && | 328 | | std::is_same_v<FormatImpl, time_format_type::yyyy_MMImpl>) { | 329 | | const auto civil_value = dt.to_date(); | 330 | | offset += FormatImpl::date_to_str(civil_value, buf); | 331 | 1 | } else if constexpr (PType == TYPE_TIMESTAMP_NS && needs_civil_datetime) { | 332 | 1 | const auto civil_value = dt.to_datetime(); | 333 | 1 | offset += FormatImpl::date_to_str(civil_value, buf); | 334 | | } else { | 335 | | offset += FormatImpl::date_to_str(dt, buf); | 336 | | } | 337 | 1 | return offset; | 338 | 1 | } |
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 |
339 | | |
340 | 22 | static DataTypes get_variadic_argument_types() { |
341 | 22 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; |
342 | 22 | } _ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE26ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type11yyyy_MMImplEXadsoKcL_ZNS_14kYearMonthNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9dd_HHImplEXadsoKcL_ZNS_12kDayHourNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12dd_HH_mmImplEXadsoKcL_ZNS_14kDayMinuteNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type15dd_HH_mm_ssImplEXadsoKcL_ZNS_14kDaySecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type22dd_HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_19kDayMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9HH_mmImplEXadsoKcL_ZNS_15kHourMinuteNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type12HH_mm_ssImplEXadsoKcL_ZNS_15kHourSecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type19HH_mm_ss_SSSSSSImplEXadsoKcL_ZNS_20kHourMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type9mm_ssImplEXadsoKcL_ZNS_17kMinuteSecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type16mm_ss_SSSSSSImplEXadsoKcL_ZNS_22kMinuteMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
_ZN5doris20DateTimeV2FormatImplILNS_13PrimitiveTypeE43ENS_16time_format_type13ss_SSSSSSImplEXadsoKcL_ZNS_22kSecondMicrosecondNameEEEEE27get_variadic_argument_typesEv Line | Count | Source | 340 | 1 | static DataTypes get_variadic_argument_types() { | 341 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>()}; | 342 | 1 | } |
|
343 | | }; |
344 | | |
345 | | inline constexpr char kYearMonthName[] = "year_month"; |
346 | | inline constexpr char kDayHourName[] = "day_hour"; |
347 | | inline constexpr char kDayMinuteName[] = "day_minute"; |
348 | | inline constexpr char kDaySecondName[] = "day_second"; |
349 | | inline constexpr char kDayMicrosecondName[] = "day_microsecond"; |
350 | | inline constexpr char kHourMinuteName[] = "hour_minute"; |
351 | | inline constexpr char kHourSecondName[] = "hour_second"; |
352 | | inline constexpr char kHourMicrosecondName[] = "hour_microsecond"; |
353 | | inline constexpr char kMinuteSecondName[] = "minute_second"; |
354 | | inline constexpr char kMinuteMicrosecondName[] = "minute_microsecond"; |
355 | | inline constexpr char kSecondMicrosecondName[] = "second_microsecond"; |
356 | | |
357 | | template <PrimitiveType PType> |
358 | | using YearMonthImpl = DateTimeV2FormatImpl<PType, time_format_type::yyyy_MMImpl, kYearMonthName>; |
359 | | template <PrimitiveType PType> |
360 | | using DayHourImpl = DateTimeV2FormatImpl<PType, time_format_type::dd_HHImpl, kDayHourName>; |
361 | | template <PrimitiveType PType> |
362 | | using DayMinuteImpl = DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mmImpl, kDayMinuteName>; |
363 | | template <PrimitiveType PType> |
364 | | using DaySecondImpl = |
365 | | DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mm_ssImpl, kDaySecondName>; |
366 | | template <PrimitiveType PType> |
367 | | using DayMicrosecondImpl = |
368 | | DateTimeV2FormatImpl<PType, time_format_type::dd_HH_mm_ss_SSSSSSImpl, kDayMicrosecondName>; |
369 | | template <PrimitiveType PType> |
370 | | using HourMinuteImpl = DateTimeV2FormatImpl<PType, time_format_type::HH_mmImpl, kHourMinuteName>; |
371 | | template <PrimitiveType PType> |
372 | | using HourSecondImpl = DateTimeV2FormatImpl<PType, time_format_type::HH_mm_ssImpl, kHourSecondName>; |
373 | | template <PrimitiveType PType> |
374 | | using HourMicrosecondImpl = |
375 | | DateTimeV2FormatImpl<PType, time_format_type::HH_mm_ss_SSSSSSImpl, kHourMicrosecondName>; |
376 | | template <PrimitiveType PType> |
377 | | using MinuteSecondImpl = |
378 | | DateTimeV2FormatImpl<PType, time_format_type::mm_ssImpl, kMinuteSecondName>; |
379 | | template <PrimitiveType PType> |
380 | | using MinuteMicrosecondImpl = |
381 | | DateTimeV2FormatImpl<PType, time_format_type::mm_ss_SSSSSSImpl, kMinuteMicrosecondName>; |
382 | | template <PrimitiveType PType> |
383 | | using SecondMicrosecondImpl = |
384 | | DateTimeV2FormatImpl<PType, time_format_type::ss_SSSSSSImpl, kSecondMicrosecondName>; |
385 | | |
386 | | template <PrimitiveType PType> |
387 | | struct DateFormatImpl { |
388 | | using DateType = typename PrimitiveTypeTraits<PType>::CppType; |
389 | | using ArgType = typename PrimitiveTypeTraits<PType>::CppType; |
390 | | static constexpr PrimitiveType FromPType = PType; |
391 | | |
392 | | static constexpr auto name = "date_format"; |
393 | | |
394 | | template <typename Impl> |
395 | | static bool execute(const DateType& dt, StringRef format, ColumnString::Chars& res_data, |
396 | 26 | size_t& offset, const cctz::time_zone& time_zone) { |
397 | 26 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { |
398 | | // Handle non-special formats. |
399 | 26 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; |
400 | 26 | const bool formatted = [&]() { |
401 | 26 | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { |
402 | 17 | return dt.to_format_string_conservative( |
403 | 17 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, |
404 | 17 | static_cast<int>(dt.microsecond()) * 1000); |
405 | 17 | } else { |
406 | 9 | return dt.to_format_string_conservative(format.data, format.size, buf, |
407 | 9 | 100 + SAFE_FORMAT_STRING_MARGIN); |
408 | 9 | } |
409 | 26 | }(); _ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv Line | Count | Source | 400 | 6 | const bool formatted = [&]() { | 401 | | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | | return dt.to_format_string_conservative( | 403 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | | static_cast<int>(dt.microsecond()) * 1000); | 405 | 6 | } else { | 406 | 6 | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | 6 | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | 6 | } | 409 | 6 | }(); |
_ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv Line | Count | Source | 400 | 17 | const bool formatted = [&]() { | 401 | 17 | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | 17 | return dt.to_format_string_conservative( | 403 | 17 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | 17 | static_cast<int>(dt.microsecond()) * 1000); | 405 | | } else { | 406 | | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | | } | 409 | 17 | }(); |
_ZZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_16TimeStampNsValueENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneEENKUlvE_clEv Line | Count | Source | 400 | 3 | const bool formatted = [&]() { | 401 | | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | | return dt.to_format_string_conservative( | 403 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | | static_cast<int>(dt.microsecond()) * 1000); | 405 | 3 | } else { | 406 | 3 | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | 3 | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | 3 | } | 409 | 3 | }(); |
|
410 | 26 | if (!formatted) { |
411 | 0 | return true; |
412 | 0 | } |
413 | | |
414 | 26 | auto len = strlen(buf); |
415 | 26 | res_data.insert(buf, buf + len); |
416 | 26 | offset += len; |
417 | 26 | return false; |
418 | 26 | } else { |
419 | 0 | if (!dt.is_valid_date()) { |
420 | 0 | return true; |
421 | 0 | } |
422 | | |
423 | | // No buffer is needed here because these specially optimized formats have fixed lengths, |
424 | | // and sufficient memory has already been reserved. |
425 | 0 | const auto len = [&]() { |
426 | 0 | if constexpr (PType == TYPE_TIMESTAMP_NS) { |
427 | 0 | constexpr bool needs_civil_time = |
428 | 0 | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> || |
429 | 0 | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>; |
430 | 0 | const auto civil_value = [&]() { |
431 | 0 | if constexpr (needs_civil_time) { |
432 | 0 | return dt.to_datetime(); |
433 | 0 | } else { |
434 | 0 | return dt.to_date(); |
435 | 0 | } |
436 | 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 |
437 | 0 | return Impl::date_to_str(civil_value, (char*)res_data.data() + offset); |
438 | 0 | } else { |
439 | 0 | return Impl::date_to_str(dt, (char*)res_data.data() + offset); |
440 | 0 | } |
441 | 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 |
442 | 0 | offset += len; |
443 | |
|
444 | 0 | return false; |
445 | 0 | } |
446 | 26 | } _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE7executeINS_16time_format_type15UserDefinedImplEEEbRKNS_11DateV2ValueINS_15DateV2ValueTypeEEENS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE Line | Count | Source | 396 | 6 | size_t& offset, const cctz::time_zone& time_zone) { | 397 | 6 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 398 | | // Handle non-special formats. | 399 | 6 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 400 | 6 | const bool formatted = [&]() { | 401 | 6 | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | 6 | return dt.to_format_string_conservative( | 403 | 6 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | 6 | static_cast<int>(dt.microsecond()) * 1000); | 405 | 6 | } else { | 406 | 6 | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | 6 | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | 6 | } | 409 | 6 | }(); | 410 | 6 | if (!formatted) { | 411 | 0 | return true; | 412 | 0 | } | 413 | | | 414 | 6 | auto len = strlen(buf); | 415 | 6 | res_data.insert(buf, buf + len); | 416 | 6 | offset += len; | 417 | 6 | return false; | 418 | | } else { | 419 | | if (!dt.is_valid_date()) { | 420 | | return true; | 421 | | } | 422 | | | 423 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 424 | | // and sufficient memory has already been reserved. | 425 | | const auto len = [&]() { | 426 | | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 427 | | constexpr bool needs_civil_time = | 428 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> || | 429 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>; | 430 | | const auto civil_value = [&]() { | 431 | | if constexpr (needs_civil_time) { | 432 | | return dt.to_datetime(); | 433 | | } else { | 434 | | return dt.to_date(); | 435 | | } | 436 | | }(); | 437 | | return Impl::date_to_str(civil_value, (char*)res_data.data() + offset); | 438 | | } else { | 439 | | return Impl::date_to_str(dt, (char*)res_data.data() + offset); | 440 | | } | 441 | | }(); | 442 | | offset += len; | 443 | | | 444 | | return false; | 445 | | } | 446 | 6 | } |
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 | 396 | 17 | size_t& offset, const cctz::time_zone& time_zone) { | 397 | 17 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 398 | | // Handle non-special formats. | 399 | 17 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 400 | 17 | const bool formatted = [&]() { | 401 | 17 | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | 17 | return dt.to_format_string_conservative( | 403 | 17 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | 17 | static_cast<int>(dt.microsecond()) * 1000); | 405 | 17 | } else { | 406 | 17 | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | 17 | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | 17 | } | 409 | 17 | }(); | 410 | 17 | if (!formatted) { | 411 | 0 | return true; | 412 | 0 | } | 413 | | | 414 | 17 | auto len = strlen(buf); | 415 | 17 | res_data.insert(buf, buf + len); | 416 | 17 | offset += len; | 417 | 17 | return false; | 418 | | } else { | 419 | | if (!dt.is_valid_date()) { | 420 | | return true; | 421 | | } | 422 | | | 423 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 424 | | // and sufficient memory has already been reserved. | 425 | | const auto len = [&]() { | 426 | | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 427 | | constexpr bool needs_civil_time = | 428 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> || | 429 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>; | 430 | | const auto civil_value = [&]() { | 431 | | if constexpr (needs_civil_time) { | 432 | | return dt.to_datetime(); | 433 | | } else { | 434 | | return dt.to_date(); | 435 | | } | 436 | | }(); | 437 | | return Impl::date_to_str(civil_value, (char*)res_data.data() + offset); | 438 | | } else { | 439 | | return Impl::date_to_str(dt, (char*)res_data.data() + offset); | 440 | | } | 441 | | }(); | 442 | | offset += len; | 443 | | | 444 | | return false; | 445 | | } | 446 | 17 | } |
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 | 396 | 3 | size_t& offset, const cctz::time_zone& time_zone) { | 397 | 3 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 398 | | // Handle non-special formats. | 399 | 3 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 400 | 3 | const bool formatted = [&]() { | 401 | 3 | if constexpr (PType == PrimitiveType::TYPE_DATETIMEV2) { | 402 | 3 | return dt.to_format_string_conservative( | 403 | 3 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, | 404 | 3 | static_cast<int>(dt.microsecond()) * 1000); | 405 | 3 | } else { | 406 | 3 | return dt.to_format_string_conservative(format.data, format.size, buf, | 407 | 3 | 100 + SAFE_FORMAT_STRING_MARGIN); | 408 | 3 | } | 409 | 3 | }(); | 410 | 3 | if (!formatted) { | 411 | 0 | return true; | 412 | 0 | } | 413 | | | 414 | 3 | auto len = strlen(buf); | 415 | 3 | res_data.insert(buf, buf + len); | 416 | 3 | offset += len; | 417 | 3 | return false; | 418 | | } else { | 419 | | if (!dt.is_valid_date()) { | 420 | | return true; | 421 | | } | 422 | | | 423 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 424 | | // and sufficient memory has already been reserved. | 425 | | const auto len = [&]() { | 426 | | if constexpr (PType == TYPE_TIMESTAMP_NS) { | 427 | | constexpr bool needs_civil_time = | 428 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ssImpl> || | 429 | | std::is_same_v<Impl, time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl>; | 430 | | const auto civil_value = [&]() { | 431 | | if constexpr (needs_civil_time) { | 432 | | return dt.to_datetime(); | 433 | | } else { | 434 | | return dt.to_date(); | 435 | | } | 436 | | }(); | 437 | | return Impl::date_to_str(civil_value, (char*)res_data.data() + offset); | 438 | | } else { | 439 | | return Impl::date_to_str(dt, (char*)res_data.data() + offset); | 440 | | } | 441 | | }(); | 442 | | offset += len; | 443 | | | 444 | | return false; | 445 | | } | 446 | 3 | } |
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 |
447 | | |
448 | 3 | static DataTypes get_variadic_argument_types() { |
449 | 3 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(), |
450 | 3 | std::make_shared<DataTypeString>()}; |
451 | 3 | } _ZN5doris14DateFormatImplILNS_13PrimitiveTypeE25EE27get_variadic_argument_typesEv Line | Count | Source | 448 | 1 | static DataTypes get_variadic_argument_types() { | 449 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(), | 450 | 1 | std::make_shared<DataTypeString>()}; | 451 | 1 | } |
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE26EE27get_variadic_argument_typesEv Line | Count | Source | 448 | 1 | static DataTypes get_variadic_argument_types() { | 449 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(), | 450 | 1 | std::make_shared<DataTypeString>()}; | 451 | 1 | } |
_ZN5doris14DateFormatImplILNS_13PrimitiveTypeE43EE27get_variadic_argument_typesEv Line | Count | Source | 448 | 1 | static DataTypes get_variadic_argument_types() { | 449 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<PType>::DataType>(), | 450 | 1 | std::make_shared<DataTypeString>()}; | 451 | 1 | } |
|
452 | | }; |
453 | | |
454 | 40 | inline bool contains_from_unixtime_format_specifier(StringRef format, char specifier) { |
455 | 335 | for (size_t i = 0; i + 1 < format.size; ++i) { |
456 | | // Consume the character after every '%', so "%%n" is escaped text rather than %n. |
457 | 312 | if (format.data[i] == '%' && format.data[++i] == specifier) { |
458 | 17 | return true; |
459 | 17 | } |
460 | 312 | } |
461 | 23 | return false; |
462 | 40 | } |
463 | | |
464 | 17 | inline bool has_conflicting_from_unixtime_fraction_specifiers(StringRef format) { |
465 | | // %f formats the microsecond-rounded instant, while %n formats the original nanosecond |
466 | | // instant. For example, 0.999999500 becomes 1.000000 for %f but stays 0.999999500 for %n, |
467 | | // so one result cannot contain both fields consistently. |
468 | 17 | return contains_from_unixtime_format_specifier(format, 'f') && |
469 | 17 | contains_from_unixtime_format_specifier(format, 'n'); |
470 | 17 | } |
471 | | |
472 | | template <bool WithStringArg, bool NewVersion = false> |
473 | | struct FromUnixTimeImpl { |
474 | | using ArgType = Int64; |
475 | | static constexpr PrimitiveType FromPType = TYPE_BIGINT; |
476 | | |
477 | 4 | static DataTypes get_variadic_argument_types() { |
478 | 4 | if constexpr (WithStringArg) { |
479 | 2 | return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()}; |
480 | 2 | } else { |
481 | 2 | return {std::make_shared<DataTypeInt64>()}; |
482 | 2 | } |
483 | 4 | } _ZN5doris16FromUnixTimeImplILb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 477 | 1 | static DataTypes get_variadic_argument_types() { | 478 | | if constexpr (WithStringArg) { | 479 | | return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()}; | 480 | 1 | } else { | 481 | 1 | return {std::make_shared<DataTypeInt64>()}; | 482 | 1 | } | 483 | 1 | } |
_ZN5doris16FromUnixTimeImplILb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 477 | 1 | static DataTypes get_variadic_argument_types() { | 478 | 1 | if constexpr (WithStringArg) { | 479 | 1 | return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()}; | 480 | | } else { | 481 | | return {std::make_shared<DataTypeInt64>()}; | 482 | | } | 483 | 1 | } |
_ZN5doris16FromUnixTimeImplILb0ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 477 | 1 | static DataTypes get_variadic_argument_types() { | 478 | | if constexpr (WithStringArg) { | 479 | | return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()}; | 480 | 1 | } else { | 481 | 1 | return {std::make_shared<DataTypeInt64>()}; | 482 | 1 | } | 483 | 1 | } |
_ZN5doris16FromUnixTimeImplILb1ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 477 | 1 | static DataTypes get_variadic_argument_types() { | 478 | 1 | if constexpr (WithStringArg) { | 479 | 1 | return {std::make_shared<DataTypeInt64>(), std::make_shared<DataTypeString>()}; | 480 | | } else { | 481 | | return {std::make_shared<DataTypeInt64>()}; | 482 | | } | 483 | 1 | } |
|
484 | | static const int64_t TIMESTAMP_VALID_MAX = 32536771199; |
485 | | static constexpr auto name = NewVersion ? "from_unixtime_new" : "from_unixtime"; |
486 | | |
487 | 12 | [[nodiscard]] static bool check_valid(const ArgType& val) { |
488 | 12 | if constexpr (NewVersion) { |
489 | 12 | if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] { |
490 | 8 | return false; |
491 | 8 | } |
492 | 12 | } else { |
493 | 0 | if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] { |
494 | 0 | return false; |
495 | 0 | } |
496 | 0 | } |
497 | 4 | return true; |
498 | 12 | } Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE11check_validERKl Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE11check_validERKl _ZN5doris16FromUnixTimeImplILb0ELb1EE11check_validERKl Line | Count | Source | 487 | 10 | [[nodiscard]] static bool check_valid(const ArgType& val) { | 488 | 10 | if constexpr (NewVersion) { | 489 | 10 | if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] { | 490 | 8 | return false; | 491 | 8 | } | 492 | | } else { | 493 | | if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] { | 494 | | return false; | 495 | | } | 496 | | } | 497 | 2 | return true; | 498 | 10 | } |
_ZN5doris16FromUnixTimeImplILb1ELb1EE11check_validERKl Line | Count | Source | 487 | 2 | [[nodiscard]] static bool check_valid(const ArgType& val) { | 488 | 2 | if constexpr (NewVersion) { | 489 | 2 | if (val < 0 || val > MAX_UNIX_TIMESTAMP_WITH_TIMEZONE) [[unlikely]] { | 490 | 0 | return false; | 491 | 0 | } | 492 | | } else { | 493 | | if (val < 0 || val > TIMESTAMP_VALID_MAX) [[unlikely]] { | 494 | | return false; | 495 | | } | 496 | | } | 497 | 2 | return true; | 498 | 2 | } |
|
499 | | |
500 | | static DateV2Value<DateTimeV2ValueType> get_datetime_value(const ArgType& val, |
501 | 3 | const cctz::time_zone& time_zone) { |
502 | 3 | DateV2Value<DateTimeV2ValueType> dt; |
503 | 3 | dt.from_unixtime(val, time_zone); |
504 | 3 | return dt; |
505 | 3 | } Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb0ELb0EE18get_datetime_valueERKlRKN4cctz9time_zoneE Unexecuted instantiation: _ZN5doris16FromUnixTimeImplILb1ELb0EE18get_datetime_valueERKlRKN4cctz9time_zoneE _ZN5doris16FromUnixTimeImplILb0ELb1EE18get_datetime_valueERKlRKN4cctz9time_zoneE Line | Count | Source | 501 | 2 | const cctz::time_zone& time_zone) { | 502 | 2 | DateV2Value<DateTimeV2ValueType> dt; | 503 | 2 | dt.from_unixtime(val, time_zone); | 504 | 2 | return dt; | 505 | 2 | } |
_ZN5doris16FromUnixTimeImplILb1ELb1EE18get_datetime_valueERKlRKN4cctz9time_zoneE Line | Count | Source | 501 | 1 | const cctz::time_zone& time_zone) { | 502 | 1 | DateV2Value<DateTimeV2ValueType> dt; | 503 | 1 | dt.from_unixtime(val, time_zone); | 504 | 1 | return dt; | 505 | 1 | } |
|
506 | | |
507 | | // return true if null(result is invalid) |
508 | | template <typename Impl> |
509 | | static bool execute(const ArgType& val, StringRef format, ColumnString::Chars& res_data, |
510 | 12 | size_t& offset, const cctz::time_zone& time_zone) { |
511 | 12 | if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) { |
512 | 9 | return true; |
513 | 9 | } |
514 | 3 | DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone); |
515 | 3 | if (!dt.is_valid_date()) [[unlikely]] { |
516 | 0 | return true; |
517 | 0 | } |
518 | 3 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { |
519 | 1 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; |
520 | 1 | if (!dt.to_format_string_conservative(format.data, format.size, buf, |
521 | 1 | 100 + SAFE_FORMAT_STRING_MARGIN, 0)) { |
522 | 0 | return true; |
523 | 0 | } |
524 | | |
525 | 1 | auto len = strlen(buf); |
526 | 1 | res_data.insert(buf, buf + len); |
527 | 1 | offset += len; |
528 | 2 | } else { |
529 | | // No buffer is needed here because these specially optimized formats have fixed lengths, |
530 | | // and sufficient memory has already been reserved. |
531 | 2 | auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset); |
532 | 2 | offset += len; |
533 | 2 | } |
534 | 0 | return false; |
535 | 3 | } 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 | 510 | 10 | size_t& offset, const cctz::time_zone& time_zone) { | 511 | 10 | if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) { | 512 | 8 | return true; | 513 | 8 | } | 514 | 2 | DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone); | 515 | 2 | if (!dt.is_valid_date()) [[unlikely]] { | 516 | 0 | return true; | 517 | 0 | } | 518 | | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 519 | | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 520 | | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 521 | | 100 + SAFE_FORMAT_STRING_MARGIN, 0)) { | 522 | | return true; | 523 | | } | 524 | | | 525 | | auto len = strlen(buf); | 526 | | res_data.insert(buf, buf + len); | 527 | | offset += len; | 528 | 2 | } else { | 529 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 530 | | // and sufficient memory has already been reserved. | 531 | 2 | auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset); | 532 | 2 | offset += len; | 533 | 2 | } | 534 | 2 | return false; | 535 | 2 | } |
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 | 510 | 2 | size_t& offset, const cctz::time_zone& time_zone) { | 511 | 2 | if (!check_valid(val) || has_conflicting_from_unixtime_fraction_specifiers(format)) { | 512 | 1 | return true; | 513 | 1 | } | 514 | 1 | DateV2Value<DateTimeV2ValueType> dt = get_datetime_value(val, time_zone); | 515 | 1 | if (!dt.is_valid_date()) [[unlikely]] { | 516 | 0 | return true; | 517 | 0 | } | 518 | 1 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 519 | 1 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 520 | 1 | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 521 | 1 | 100 + SAFE_FORMAT_STRING_MARGIN, 0)) { | 522 | 0 | return true; | 523 | 0 | } | 524 | | | 525 | 1 | auto len = strlen(buf); | 526 | 1 | res_data.insert(buf, buf + len); | 527 | 1 | offset += len; | 528 | | } else { | 529 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 530 | | // and sufficient memory has already been reserved. | 531 | | auto len = Impl::date_to_str(dt, (char*)res_data.data() + offset); | 532 | | offset += len; | 533 | | } | 534 | 0 | return false; | 535 | 1 | } |
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 |
536 | | }; |
537 | | |
538 | | // only new verison |
539 | | template <bool WithStringArg, bool WithNanosecond = false> |
540 | | struct FromUnixTimeDecimalImpl { |
541 | | static_assert(!WithNanosecond || WithStringArg); |
542 | | using ArgType = std::conditional_t<WithNanosecond, Int128, Int64>; |
543 | | static constexpr PrimitiveType FromPType = WithNanosecond ? TYPE_DECIMAL128I : TYPE_DECIMAL64; |
544 | | constexpr static short Scale = WithNanosecond ? 9 : 6; |
545 | | |
546 | 3 | static DataTypes get_variadic_argument_types() { |
547 | 3 | if constexpr (WithStringArg) { |
548 | 2 | if constexpr (WithNanosecond) { |
549 | 1 | return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()}; |
550 | 1 | } |
551 | 0 | return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()}; |
552 | 2 | } else { |
553 | 1 | return {std::make_shared<DataTypeDecimal64>()}; |
554 | 1 | } |
555 | 3 | } _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 546 | 1 | static DataTypes get_variadic_argument_types() { | 547 | | if constexpr (WithStringArg) { | 548 | | if constexpr (WithNanosecond) { | 549 | | return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()}; | 550 | | } | 551 | | return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()}; | 552 | 1 | } else { | 553 | 1 | return {std::make_shared<DataTypeDecimal64>()}; | 554 | 1 | } | 555 | 1 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE27get_variadic_argument_typesEv Line | Count | Source | 546 | 1 | static DataTypes get_variadic_argument_types() { | 547 | 1 | if constexpr (WithStringArg) { | 548 | | if constexpr (WithNanosecond) { | 549 | | return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()}; | 550 | | } | 551 | 1 | return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()}; | 552 | | } else { | 553 | | return {std::make_shared<DataTypeDecimal64>()}; | 554 | | } | 555 | 1 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE27get_variadic_argument_typesEv Line | Count | Source | 546 | 1 | static DataTypes get_variadic_argument_types() { | 547 | 1 | if constexpr (WithStringArg) { | 548 | 1 | if constexpr (WithNanosecond) { | 549 | 1 | return {std::make_shared<DataTypeDecimal128>(), std::make_shared<DataTypeString>()}; | 550 | 1 | } | 551 | 0 | return {std::make_shared<DataTypeDecimal64>(), std::make_shared<DataTypeString>()}; | 552 | | } else { | 553 | | return {std::make_shared<DataTypeDecimal64>()}; | 554 | | } | 555 | 1 | } |
|
556 | | static constexpr auto name = "from_unixtime_new"; |
557 | | |
558 | 11 | [[nodiscard]] static bool check_valid(const ArgType& val) { |
559 | 11 | if (val < 0) [[unlikely]] { |
560 | 0 | return false; |
561 | 0 | } |
562 | 11 | return true; |
563 | 11 | } _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE11check_validERKl Line | Count | Source | 558 | 2 | [[nodiscard]] static bool check_valid(const ArgType& val) { | 559 | 2 | if (val < 0) [[unlikely]] { | 560 | 0 | return false; | 561 | 0 | } | 562 | 2 | return true; | 563 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE11check_validERKl Line | Count | Source | 558 | 2 | [[nodiscard]] static bool check_valid(const ArgType& val) { | 559 | 2 | if (val < 0) [[unlikely]] { | 560 | 0 | return false; | 561 | 0 | } | 562 | 2 | return true; | 563 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE11check_validERKn Line | Count | Source | 558 | 7 | [[nodiscard]] static bool check_valid(const ArgType& val) { | 559 | 7 | if (val < 0) [[unlikely]] { | 560 | 0 | return false; | 561 | 0 | } | 562 | 7 | return true; | 563 | 7 | } |
|
564 | | |
565 | 16 | static int32_t get_nanosecond(const ArgType& fraction) { |
566 | 16 | return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale); |
567 | 16 | } _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE14get_nanosecondERKl Line | Count | Source | 565 | 2 | static int32_t get_nanosecond(const ArgType& fraction) { | 566 | 2 | return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale); | 567 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE14get_nanosecondERKl Line | Count | Source | 565 | 4 | static int32_t get_nanosecond(const ArgType& fraction) { | 566 | 4 | return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale); | 567 | 4 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE14get_nanosecondERKn Line | Count | Source | 565 | 10 | static int32_t get_nanosecond(const ArgType& fraction) { | 566 | 10 | return static_cast<int32_t>(fraction) * common::exp10_i32(9 - Scale); | 567 | 10 | } |
|
568 | | |
569 | | static DateV2Value<DateTimeV2ValueType> get_datetime_value(const ArgType& interger, |
570 | | const ArgType& fraction, |
571 | | const cctz::time_zone& time_zone, |
572 | 11 | bool preserve_nanosecond) { |
573 | 11 | auto epoch_second = static_cast<int64_t>(interger); |
574 | 11 | int32_t nanosecond = get_nanosecond(fraction); |
575 | 11 | if constexpr (WithNanosecond) { |
576 | 7 | if (!preserve_nanosecond) { |
577 | | // Keep the established %f behavior by rounding the complete instant, including |
578 | | // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000. |
579 | 5 | constexpr int32_t MICROS_PER_SECOND = 1000000; |
580 | 5 | const int32_t rounded_microseconds = |
581 | 5 | (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) / |
582 | 5 | TimeStampNsValue::NANOS_PER_MICROSECOND; |
583 | 5 | epoch_second += rounded_microseconds / MICROS_PER_SECOND; |
584 | 5 | nanosecond = rounded_microseconds % MICROS_PER_SECOND * |
585 | 5 | TimeStampNsValue::NANOS_PER_MICROSECOND; |
586 | 5 | } |
587 | 7 | } |
588 | 11 | DateV2Value<DateTimeV2ValueType> dt; |
589 | 11 | dt.from_unixtime(epoch_second, nanosecond, time_zone, 6); |
590 | 11 | return dt; |
591 | 11 | } _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE18get_datetime_valueERKlS3_RKN4cctz9time_zoneEb Line | Count | Source | 572 | 2 | bool preserve_nanosecond) { | 573 | 2 | auto epoch_second = static_cast<int64_t>(interger); | 574 | 2 | int32_t nanosecond = get_nanosecond(fraction); | 575 | | if constexpr (WithNanosecond) { | 576 | | if (!preserve_nanosecond) { | 577 | | // Keep the established %f behavior by rounding the complete instant, including | 578 | | // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000. | 579 | | constexpr int32_t MICROS_PER_SECOND = 1000000; | 580 | | const int32_t rounded_microseconds = | 581 | | (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) / | 582 | | TimeStampNsValue::NANOS_PER_MICROSECOND; | 583 | | epoch_second += rounded_microseconds / MICROS_PER_SECOND; | 584 | | nanosecond = rounded_microseconds % MICROS_PER_SECOND * | 585 | | TimeStampNsValue::NANOS_PER_MICROSECOND; | 586 | | } | 587 | | } | 588 | 2 | DateV2Value<DateTimeV2ValueType> dt; | 589 | 2 | dt.from_unixtime(epoch_second, nanosecond, time_zone, 6); | 590 | 2 | return dt; | 591 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb0EE18get_datetime_valueERKlS3_RKN4cctz9time_zoneEb Line | Count | Source | 572 | 2 | bool preserve_nanosecond) { | 573 | 2 | auto epoch_second = static_cast<int64_t>(interger); | 574 | 2 | int32_t nanosecond = get_nanosecond(fraction); | 575 | | if constexpr (WithNanosecond) { | 576 | | if (!preserve_nanosecond) { | 577 | | // Keep the established %f behavior by rounding the complete instant, including | 578 | | // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000. | 579 | | constexpr int32_t MICROS_PER_SECOND = 1000000; | 580 | | const int32_t rounded_microseconds = | 581 | | (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) / | 582 | | TimeStampNsValue::NANOS_PER_MICROSECOND; | 583 | | epoch_second += rounded_microseconds / MICROS_PER_SECOND; | 584 | | nanosecond = rounded_microseconds % MICROS_PER_SECOND * | 585 | | TimeStampNsValue::NANOS_PER_MICROSECOND; | 586 | | } | 587 | | } | 588 | 2 | DateV2Value<DateTimeV2ValueType> dt; | 589 | 2 | dt.from_unixtime(epoch_second, nanosecond, time_zone, 6); | 590 | 2 | return dt; | 591 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE18get_datetime_valueERKnS3_RKN4cctz9time_zoneEb Line | Count | Source | 572 | 7 | bool preserve_nanosecond) { | 573 | 7 | auto epoch_second = static_cast<int64_t>(interger); | 574 | 7 | int32_t nanosecond = get_nanosecond(fraction); | 575 | 7 | if constexpr (WithNanosecond) { | 576 | 7 | if (!preserve_nanosecond) { | 577 | | // Keep the established %f behavior by rounding the complete instant, including | 578 | | // carry: 0.999999500 seconds is formatted as 01.000000, not 00.000000. | 579 | 5 | constexpr int32_t MICROS_PER_SECOND = 1000000; | 580 | 5 | const int32_t rounded_microseconds = | 581 | 5 | (nanosecond + TimeStampNsValue::NANOS_PER_MICROSECOND / 2) / | 582 | 5 | TimeStampNsValue::NANOS_PER_MICROSECOND; | 583 | 5 | epoch_second += rounded_microseconds / MICROS_PER_SECOND; | 584 | 5 | nanosecond = rounded_microseconds % MICROS_PER_SECOND * | 585 | 5 | TimeStampNsValue::NANOS_PER_MICROSECOND; | 586 | 5 | } | 587 | 7 | } | 588 | 7 | DateV2Value<DateTimeV2ValueType> dt; | 589 | 7 | dt.from_unixtime(epoch_second, nanosecond, time_zone, 6); | 590 | 7 | return dt; | 591 | 7 | } |
|
592 | | |
593 | | // return true if null(result is invalid) |
594 | | template <typename Impl> |
595 | | static bool execute_decimal(const ArgType& interger, const ArgType& fraction, StringRef format, |
596 | | ColumnString::Chars& res_data, size_t& offset, |
597 | 13 | const cctz::time_zone& time_zone) { |
598 | 13 | if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] { |
599 | 2 | return true; |
600 | 2 | } |
601 | 11 | int64_t fraction_adjustment = 0; |
602 | 11 | if (fraction > 0) { |
603 | 11 | fraction_adjustment = 1; |
604 | 11 | } else if (fraction < 0) { |
605 | 0 | fraction_adjustment = -1; |
606 | 0 | } |
607 | 11 | if (!check_valid(interger + fraction_adjustment)) [[unlikely]] { |
608 | 0 | return true; |
609 | 0 | } |
610 | 11 | const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n'); |
611 | 11 | DateV2Value<DateTimeV2ValueType> dt = |
612 | 11 | get_datetime_value(interger, fraction, time_zone, preserve_nanosecond); |
613 | 11 | if (!dt.is_valid_date()) [[unlikely]] { |
614 | 0 | return true; |
615 | 0 | } |
616 | 11 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { |
617 | 5 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; |
618 | 5 | if (!dt.to_format_string_conservative(format.data, format.size, buf, |
619 | 5 | 100 + SAFE_FORMAT_STRING_MARGIN, |
620 | 5 | get_nanosecond(fraction))) { |
621 | 0 | return true; |
622 | 0 | } |
623 | | |
624 | 5 | auto len = strlen(buf); |
625 | 5 | res_data.insert(buf, buf + len); |
626 | 5 | offset += len; |
627 | 6 | } else { |
628 | | // No buffer is needed here because these specially optimized formats have fixed lengths, |
629 | | // and sufficient memory has already been reserved. |
630 | 6 | auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str( |
631 | 6 | dt, (char*)res_data.data() + offset); |
632 | 6 | offset += len; |
633 | 6 | } |
634 | 0 | return false; |
635 | 11 | } _ZN5doris23FromUnixTimeDecimalImplILb0ELb0EE15execute_decimalINS_16time_format_type30yyyy_MM_dd_HH_mm_ss_SSSSSSImplEEEbRKlS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE Line | Count | Source | 597 | 2 | const cctz::time_zone& time_zone) { | 598 | 2 | if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] { | 599 | 0 | return true; | 600 | 0 | } | 601 | 2 | int64_t fraction_adjustment = 0; | 602 | 2 | if (fraction > 0) { | 603 | 2 | fraction_adjustment = 1; | 604 | 2 | } else if (fraction < 0) { | 605 | 0 | fraction_adjustment = -1; | 606 | 0 | } | 607 | 2 | if (!check_valid(interger + fraction_adjustment)) [[unlikely]] { | 608 | 0 | return true; | 609 | 0 | } | 610 | 2 | const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n'); | 611 | 2 | DateV2Value<DateTimeV2ValueType> dt = | 612 | 2 | get_datetime_value(interger, fraction, time_zone, preserve_nanosecond); | 613 | 2 | if (!dt.is_valid_date()) [[unlikely]] { | 614 | 0 | return true; | 615 | 0 | } | 616 | | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 617 | | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 618 | | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 619 | | 100 + SAFE_FORMAT_STRING_MARGIN, | 620 | | get_nanosecond(fraction))) { | 621 | | return true; | 622 | | } | 623 | | | 624 | | auto len = strlen(buf); | 625 | | res_data.insert(buf, buf + len); | 626 | | offset += len; | 627 | 2 | } else { | 628 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 629 | | // and sufficient memory has already been reserved. | 630 | 2 | auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str( | 631 | 2 | dt, (char*)res_data.data() + offset); | 632 | 2 | offset += len; | 633 | 2 | } | 634 | 2 | return false; | 635 | 2 | } |
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 | 597 | 3 | const cctz::time_zone& time_zone) { | 598 | 3 | if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] { | 599 | 1 | return true; | 600 | 1 | } | 601 | 2 | int64_t fraction_adjustment = 0; | 602 | 2 | if (fraction > 0) { | 603 | 2 | fraction_adjustment = 1; | 604 | 2 | } else if (fraction < 0) { | 605 | 0 | fraction_adjustment = -1; | 606 | 0 | } | 607 | 2 | if (!check_valid(interger + fraction_adjustment)) [[unlikely]] { | 608 | 0 | return true; | 609 | 0 | } | 610 | 2 | const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n'); | 611 | 2 | DateV2Value<DateTimeV2ValueType> dt = | 612 | 2 | get_datetime_value(interger, fraction, time_zone, preserve_nanosecond); | 613 | 2 | if (!dt.is_valid_date()) [[unlikely]] { | 614 | 0 | return true; | 615 | 0 | } | 616 | 2 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 617 | 2 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 618 | 2 | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 619 | 2 | 100 + SAFE_FORMAT_STRING_MARGIN, | 620 | 2 | get_nanosecond(fraction))) { | 621 | 0 | return true; | 622 | 0 | } | 623 | | | 624 | 2 | auto len = strlen(buf); | 625 | 2 | res_data.insert(buf, buf + len); | 626 | 2 | offset += len; | 627 | | } else { | 628 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 629 | | // and sufficient memory has already been reserved. | 630 | | auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str( | 631 | | dt, (char*)res_data.data() + offset); | 632 | | offset += len; | 633 | | } | 634 | 0 | return false; | 635 | 2 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE15execute_decimalINS_16time_format_type30yyyy_MM_dd_HH_mm_ss_SSSSSSImplEEEbRKnS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE Line | Count | Source | 597 | 4 | const cctz::time_zone& time_zone) { | 598 | 4 | if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] { | 599 | 0 | return true; | 600 | 0 | } | 601 | 4 | int64_t fraction_adjustment = 0; | 602 | 4 | if (fraction > 0) { | 603 | 4 | fraction_adjustment = 1; | 604 | 4 | } else if (fraction < 0) { | 605 | 0 | fraction_adjustment = -1; | 606 | 0 | } | 607 | 4 | if (!check_valid(interger + fraction_adjustment)) [[unlikely]] { | 608 | 0 | return true; | 609 | 0 | } | 610 | 4 | const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n'); | 611 | 4 | DateV2Value<DateTimeV2ValueType> dt = | 612 | 4 | get_datetime_value(interger, fraction, time_zone, preserve_nanosecond); | 613 | 4 | if (!dt.is_valid_date()) [[unlikely]] { | 614 | 0 | return true; | 615 | 0 | } | 616 | | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 617 | | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 618 | | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 619 | | 100 + SAFE_FORMAT_STRING_MARGIN, | 620 | | get_nanosecond(fraction))) { | 621 | | return true; | 622 | | } | 623 | | | 624 | | auto len = strlen(buf); | 625 | | res_data.insert(buf, buf + len); | 626 | | offset += len; | 627 | 4 | } else { | 628 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 629 | | // and sufficient memory has already been reserved. | 630 | 4 | auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str( | 631 | 4 | dt, (char*)res_data.data() + offset); | 632 | 4 | offset += len; | 633 | 4 | } | 634 | 4 | return false; | 635 | 4 | } |
_ZN5doris23FromUnixTimeDecimalImplILb1ELb1EE15execute_decimalINS_16time_format_type15UserDefinedImplEEEbRKnS6_NS_9StringRefERNS_8PODArrayIhLm4096ENS_9AllocatorILb0ELb0ELb0ENS_22DefaultMemoryAllocatorELb1EEELm16ELm15EEERmRKN4cctz9time_zoneE Line | Count | Source | 597 | 4 | const cctz::time_zone& time_zone) { | 598 | 4 | if (has_conflicting_from_unixtime_fraction_specifiers(format)) [[unlikely]] { | 599 | 1 | return true; | 600 | 1 | } | 601 | 3 | int64_t fraction_adjustment = 0; | 602 | 3 | if (fraction > 0) { | 603 | 3 | fraction_adjustment = 1; | 604 | 3 | } else if (fraction < 0) { | 605 | 0 | fraction_adjustment = -1; | 606 | 0 | } | 607 | 3 | if (!check_valid(interger + fraction_adjustment)) [[unlikely]] { | 608 | 0 | return true; | 609 | 0 | } | 610 | 3 | const bool preserve_nanosecond = contains_from_unixtime_format_specifier(format, 'n'); | 611 | 3 | DateV2Value<DateTimeV2ValueType> dt = | 612 | 3 | get_datetime_value(interger, fraction, time_zone, preserve_nanosecond); | 613 | 3 | if (!dt.is_valid_date()) [[unlikely]] { | 614 | 0 | return true; | 615 | 0 | } | 616 | 3 | if constexpr (std::is_same_v<Impl, time_format_type::UserDefinedImpl>) { | 617 | 3 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 618 | 3 | if (!dt.to_format_string_conservative(format.data, format.size, buf, | 619 | 3 | 100 + SAFE_FORMAT_STRING_MARGIN, | 620 | 3 | get_nanosecond(fraction))) { | 621 | 0 | return true; | 622 | 0 | } | 623 | | | 624 | 3 | auto len = strlen(buf); | 625 | 3 | res_data.insert(buf, buf + len); | 626 | 3 | offset += len; | 627 | | } else { | 628 | | // No buffer is needed here because these specially optimized formats have fixed lengths, | 629 | | // and sufficient memory has already been reserved. | 630 | | auto len = time_format_type::yyyy_MM_dd_HH_mm_ss_SSSSSSImpl::date_to_str( | 631 | | dt, (char*)res_data.data() + offset); | 632 | | offset += len; | 633 | | } | 634 | 0 | return false; | 635 | 3 | } |
|
636 | | }; |
637 | | |
638 | | // Base template for optimized time field(HOUR, MINUTE, SECOND, MS) extraction from Unix timestamp |
639 | | // Uses lookup_offset to avoid expensive civil_second construction |
640 | | template <typename Impl> |
641 | | class FunctionTimeFieldFromUnixtime : public IFunction { |
642 | | public: |
643 | | static constexpr auto name = Impl::name; |
644 | 8 | static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); }_ZN5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE6createEv Line | Count | Source | 644 | 2 | static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); } |
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE6createEv Line | Count | Source | 644 | 2 | static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); } |
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE6createEv Line | Count | Source | 644 | 2 | static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); } |
_ZN5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE6createEv Line | Count | Source | 644 | 2 | static FunctionPtr create() { return std::make_shared<FunctionTimeFieldFromUnixtime<Impl>>(); } |
|
645 | | |
646 | 4 | String get_name() const override { return name; }_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_20HourFromUnixtimeImplEE8get_nameB5cxx11Ev Line | Count | Source | 646 | 1 | String get_name() const override { return name; } |
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22MinuteFromUnixtimeImplEE8get_nameB5cxx11Ev Line | Count | Source | 646 | 1 | String get_name() const override { return name; } |
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_22SecondFromUnixtimeImplEE8get_nameB5cxx11Ev Line | Count | Source | 646 | 1 | String get_name() const override { return name; } |
_ZNK5doris29FunctionTimeFieldFromUnixtimeINS_27MicrosecondFromUnixtimeImplEE8get_nameB5cxx11Ev Line | Count | Source | 646 | 1 | String get_name() const override { return name; } |
|
647 | | |
648 | 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 |
649 | | |
650 | 0 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { |
651 | | // microsecond_from_unixtime returns Int32, others (hour/minute/second) return Int8 |
652 | 0 | if constexpr (Impl::ArgType == PrimitiveType::TYPE_DECIMAL64) { |
653 | 0 | return make_nullable(std::make_shared<DataTypeInt32>()); |
654 | 0 | } else { |
655 | 0 | return make_nullable(std::make_shared<DataTypeInt8>()); |
656 | 0 | } |
657 | 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 |
658 | | |
659 | | // (UTC 9999-12-31 23:59:59) - 24 * 3600 |
660 | | static const int64_t TIMESTAMP_VALID_MAX = 253402243199L; |
661 | | |
662 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
663 | 0 | uint32_t result, size_t input_rows_count) const override { |
664 | 0 | using ArgColType = typename PrimitiveTypeTraits<Impl::ArgType>::ColumnType; |
665 | 0 | using ResColType = std::conditional_t<Impl::ArgType == PrimitiveType::TYPE_DECIMAL64, |
666 | 0 | ColumnInt32, ColumnInt8>; |
667 | 0 | using ResItemType = typename ResColType::value_type; |
668 | 0 | auto res = ResColType::create(); |
669 | |
|
670 | 0 | const auto* ts_col = |
671 | 0 | assert_cast<const ArgColType*>(block.get_by_position(arguments[0]).column.get()); |
672 | 0 | if constexpr (Impl::ArgType == PrimitiveType::TYPE_DECIMAL64) { |
673 | | // microsecond_from_unixtime only |
674 | 0 | const auto scale = static_cast<int32_t>(ts_col->get_scale()); |
675 | |
|
676 | 0 | for (int i = 0; i < input_rows_count; ++i) { |
677 | 0 | const auto seconds = ts_col->get_intergral_part(i); |
678 | 0 | const auto fraction = ts_col->get_fractional_part(i); |
679 | |
|
680 | 0 | if (seconds < 0 || seconds > TIMESTAMP_VALID_MAX) { |
681 | 0 | return Status::InvalidArgument( |
682 | 0 | "The input value of TimeFiled(from_unixtime()) must between 0 and " |
683 | 0 | "253402243199L"); |
684 | 0 | } |
685 | | |
686 | 0 | ResItemType value = Impl::extract_field(fraction, scale); |
687 | 0 | res->insert_value(value); |
688 | 0 | } |
689 | 0 | } else { |
690 | 0 | auto ctz = context->state()->timezone_obj(); |
691 | 0 | for (int i = 0; i < input_rows_count; ++i) { |
692 | 0 | auto date = ts_col->get_element(i); |
693 | |
|
694 | 0 | if (date < 0 || date > TIMESTAMP_VALID_MAX) { |
695 | 0 | return Status::InvalidArgument( |
696 | 0 | "The input value of TimeFiled(from_unixtime()) must between 0 and " |
697 | 0 | "253402243199L"); |
698 | 0 | } |
699 | | |
700 | 0 | ResItemType value = Impl::extract_field(date, ctz); |
701 | 0 | res->insert_value(value); |
702 | 0 | } |
703 | 0 | } |
704 | 0 | block.replace_by_position(result, std::move(res)); |
705 | 0 | return Status::OK(); |
706 | 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 |
707 | | }; |
708 | | |
709 | | struct HourFromUnixtimeImpl { |
710 | | static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT; |
711 | | static constexpr auto name = "hour_from_unixtime"; |
712 | | |
713 | 0 | static int8_t extract_field(int64_t local_time, const cctz::time_zone& ctz) { |
714 | 0 | static const auto epoch = std::chrono::time_point_cast<cctz::sys_seconds>( |
715 | 0 | std::chrono::system_clock::from_time_t(0)); |
716 | 0 | cctz::time_point<cctz::sys_seconds> t = epoch + cctz::seconds(local_time); |
717 | 0 | int offset = ctz.lookup_offset(t).offset; |
718 | 0 | local_time += offset; |
719 | |
|
720 | 0 | static const libdivide::divider<int64_t> fast_div_3600(3600); |
721 | 0 | static const libdivide::divider<int64_t> fast_div_86400(86400); |
722 | |
|
723 | 0 | int64_t remainder; |
724 | 0 | if (LIKELY(local_time >= 0)) { |
725 | 0 | remainder = local_time - local_time / fast_div_86400 * 86400; |
726 | 0 | } else { |
727 | 0 | remainder = local_time % 86400; |
728 | 0 | if (remainder < 0) { |
729 | 0 | remainder += 86400; |
730 | 0 | } |
731 | 0 | } |
732 | 0 | return static_cast<int8_t>(remainder / fast_div_3600); |
733 | 0 | } |
734 | | }; |
735 | | |
736 | | struct MinuteFromUnixtimeImpl { |
737 | | static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT; |
738 | | static constexpr auto name = "minute_from_unixtime"; |
739 | | |
740 | 0 | static int8_t extract_field(int64_t local_time, const cctz::time_zone& /*ctz*/) { |
741 | 0 | static const libdivide::divider<int64_t> fast_div_60(60); |
742 | 0 | static const libdivide::divider<int64_t> fast_div_3600(3600); |
743 | |
|
744 | 0 | local_time = local_time - local_time / fast_div_3600 * 3600; |
745 | |
|
746 | 0 | return static_cast<int8_t>(local_time / fast_div_60); |
747 | 0 | } |
748 | | }; |
749 | | |
750 | | struct SecondFromUnixtimeImpl { |
751 | | static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_BIGINT; |
752 | | static constexpr auto name = "second_from_unixtime"; |
753 | | |
754 | 0 | static int8_t extract_field(int64_t local_time, const cctz::time_zone& /*ctz*/) { |
755 | 0 | return static_cast<int8_t>(local_time % 60); |
756 | 0 | } |
757 | | }; |
758 | | |
759 | | struct MicrosecondFromUnixtimeImpl { |
760 | | static constexpr PrimitiveType ArgType = PrimitiveType::TYPE_DECIMAL64; |
761 | | static constexpr auto name = "microsecond_from_unixtime"; |
762 | | |
763 | 0 | static int32_t extract_field(int64_t fraction, int scale) { |
764 | 0 | if (scale < 6) { |
765 | 0 | fraction *= common::exp10_i64(6 - scale); |
766 | 0 | } |
767 | 0 | return static_cast<int32_t>(fraction); |
768 | 0 | } |
769 | | }; |
770 | | |
771 | | template <PrimitiveType ArgPType> |
772 | | class FunctionTimeFormat : public IFunction { |
773 | | public: |
774 | | using ArgColType = typename PrimitiveTypeTraits<ArgPType>::ColumnType; |
775 | | using ArgCppType = typename PrimitiveTypeTraits<ArgPType>::CppType; |
776 | | |
777 | | static constexpr auto name = "time_format"; |
778 | 4 | String get_name() const override { return name; }_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE8get_nameB5cxx11Ev Line | Count | Source | 778 | 1 | String get_name() const override { return name; } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE8get_nameB5cxx11Ev Line | Count | Source | 778 | 1 | String get_name() const override { return name; } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE8get_nameB5cxx11Ev Line | Count | Source | 778 | 1 | String get_name() const override { return name; } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE8get_nameB5cxx11Ev Line | Count | Source | 778 | 1 | String get_name() const override { return name; } |
|
779 | 13 | static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); }_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE6createEv Line | Count | Source | 779 | 2 | static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); } |
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE6createEv Line | Count | Source | 779 | 3 | static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); } |
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE6createEv Line | Count | Source | 779 | 3 | static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); } |
_ZN5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE6createEv Line | Count | Source | 779 | 5 | static FunctionPtr create() { return std::make_shared<FunctionTimeFormat>(); } |
|
780 | 4 | DataTypes get_variadic_argument_types_impl() const override { |
781 | 4 | return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(), |
782 | 4 | std::make_shared<DataTypeString>()}; |
783 | 4 | } _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE32get_variadic_argument_types_implEv Line | Count | Source | 780 | 1 | DataTypes get_variadic_argument_types_impl() const override { | 781 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(), | 782 | 1 | std::make_shared<DataTypeString>()}; | 783 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE32get_variadic_argument_types_implEv Line | Count | Source | 780 | 1 | DataTypes get_variadic_argument_types_impl() const override { | 781 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(), | 782 | 1 | std::make_shared<DataTypeString>()}; | 783 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE32get_variadic_argument_types_implEv Line | Count | Source | 780 | 1 | DataTypes get_variadic_argument_types_impl() const override { | 781 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(), | 782 | 1 | std::make_shared<DataTypeString>()}; | 783 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE32get_variadic_argument_types_implEv Line | Count | Source | 780 | 1 | DataTypes get_variadic_argument_types_impl() const override { | 781 | 1 | return {std::make_shared<typename PrimitiveTypeTraits<ArgPType>::DataType>(), | 782 | 1 | std::make_shared<DataTypeString>()}; | 783 | 1 | } |
|
784 | 5 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { |
785 | 5 | return make_nullable(std::make_shared<DataTypeString>()); |
786 | 5 | } Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE Line | Count | Source | 784 | 1 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 785 | 1 | return make_nullable(std::make_shared<DataTypeString>()); | 786 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE Line | Count | Source | 784 | 1 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 785 | 1 | return make_nullable(std::make_shared<DataTypeString>()); | 786 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE20get_return_type_implERKSt6vectorINS_21ColumnWithTypeAndNameESaIS4_EE Line | Count | Source | 784 | 3 | DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { | 785 | 3 | return make_nullable(std::make_shared<DataTypeString>()); | 786 | 3 | } |
|
787 | 5 | 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 | 787 | 1 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE23get_number_of_argumentsEv Line | Count | Source | 787 | 1 | size_t get_number_of_arguments() const override { return 2; } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE23get_number_of_argumentsEv Line | Count | Source | 787 | 3 | size_t get_number_of_arguments() const override { return 2; } |
|
788 | | |
789 | | Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
790 | 5 | uint32_t result, size_t input_rows_count) const override { |
791 | 5 | auto res_col = ColumnString::create(); |
792 | 5 | ColumnString::Chars& res_chars = res_col->get_chars(); |
793 | 5 | ColumnString::Offsets& res_offsets = res_col->get_offsets(); |
794 | | |
795 | 5 | auto null_map = ColumnUInt8::create(); |
796 | 5 | auto& null_map_data = null_map->get_data(); |
797 | 5 | null_map_data.resize_fill(input_rows_count, 0); |
798 | | |
799 | 5 | res_offsets.reserve(input_rows_count); |
800 | | |
801 | 5 | ColumnPtr arg_col[2]; |
802 | 5 | bool is_const[2]; |
803 | 15 | for (size_t i = 0; i < 2; ++i) { |
804 | 10 | const ColumnPtr& col = block.get_by_position(arguments[i]).column; |
805 | 10 | std::tie(arg_col[i], is_const[i]) = unpack_if_const(col); |
806 | 10 | } |
807 | | |
808 | 5 | const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get()); |
809 | 5 | const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get()); |
810 | 10 | for (size_t i = 0; i < input_rows_count; ++i) { |
811 | 5 | const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0])); |
812 | 5 | StringRef format = format_col->get_data_at(index_check_const(i, is_const[1])); |
813 | 5 | TimeValue::TimeType time = get_time_value(datetime_val); |
814 | | |
815 | 5 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; |
816 | 5 | const bool formatted = [&]() { |
817 | 5 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { |
818 | 1 | return TimeValue::to_format_string_conservative( |
819 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, |
820 | 1 | datetime_val.nanosecond()); |
821 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || |
822 | 4 | ArgPType == PrimitiveType::TYPE_TIMEV2) { |
823 | 4 | return TimeValue::to_format_string_conservative( |
824 | 4 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, |
825 | 4 | TimeValue::microsecond(time) * 1000); |
826 | 4 | } else { |
827 | 0 | return TimeValue::to_format_string_conservative( |
828 | 0 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); |
829 | 0 | } |
830 | 5 | }(); Unexecuted instantiation: _ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv _ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv Line | Count | Source | 816 | 1 | const bool formatted = [&]() { | 817 | | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | | return TimeValue::to_format_string_conservative( | 819 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | | datetime_val.nanosecond()); | 821 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | 1 | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | 1 | return TimeValue::to_format_string_conservative( | 824 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | 1 | TimeValue::microsecond(time) * 1000); | 826 | | } else { | 827 | | return TimeValue::to_format_string_conservative( | 828 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | | } | 830 | 1 | }(); |
_ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv Line | Count | Source | 816 | 1 | const bool formatted = [&]() { | 817 | 1 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | 1 | return TimeValue::to_format_string_conservative( | 819 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | 1 | datetime_val.nanosecond()); | 821 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | | return TimeValue::to_format_string_conservative( | 824 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | | TimeValue::microsecond(time) * 1000); | 826 | | } else { | 827 | | return TimeValue::to_format_string_conservative( | 828 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | | } | 830 | 1 | }(); |
_ZZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmENKUlvE_clEv Line | Count | Source | 816 | 3 | const bool formatted = [&]() { | 817 | | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | | return TimeValue::to_format_string_conservative( | 819 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | | datetime_val.nanosecond()); | 821 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | 3 | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | 3 | return TimeValue::to_format_string_conservative( | 824 | 3 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | 3 | TimeValue::microsecond(time) * 1000); | 826 | | } else { | 827 | | return TimeValue::to_format_string_conservative( | 828 | | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | | } | 830 | 3 | }(); |
|
831 | 5 | if (!formatted) { |
832 | 0 | null_map_data[i] = 1; |
833 | 0 | res_offsets.push_back(res_chars.size()); |
834 | 0 | continue; |
835 | 0 | } |
836 | 5 | res_chars.insert(buf, buf + strlen(buf)); |
837 | 5 | res_offsets.push_back(res_chars.size()); |
838 | 5 | } |
839 | 5 | block.replace_by_position(result, |
840 | 5 | ColumnNullable::create(std::move(res_col), std::move(null_map))); |
841 | 5 | return Status::OK(); |
842 | 5 | } Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 790 | 1 | uint32_t result, size_t input_rows_count) const override { | 791 | 1 | auto res_col = ColumnString::create(); | 792 | 1 | ColumnString::Chars& res_chars = res_col->get_chars(); | 793 | 1 | ColumnString::Offsets& res_offsets = res_col->get_offsets(); | 794 | | | 795 | 1 | auto null_map = ColumnUInt8::create(); | 796 | 1 | auto& null_map_data = null_map->get_data(); | 797 | 1 | null_map_data.resize_fill(input_rows_count, 0); | 798 | | | 799 | 1 | res_offsets.reserve(input_rows_count); | 800 | | | 801 | 1 | ColumnPtr arg_col[2]; | 802 | 1 | bool is_const[2]; | 803 | 3 | for (size_t i = 0; i < 2; ++i) { | 804 | 2 | const ColumnPtr& col = block.get_by_position(arguments[i]).column; | 805 | 2 | std::tie(arg_col[i], is_const[i]) = unpack_if_const(col); | 806 | 2 | } | 807 | | | 808 | 1 | const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get()); | 809 | 1 | const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get()); | 810 | 2 | for (size_t i = 0; i < input_rows_count; ++i) { | 811 | 1 | const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0])); | 812 | 1 | StringRef format = format_col->get_data_at(index_check_const(i, is_const[1])); | 813 | 1 | TimeValue::TimeType time = get_time_value(datetime_val); | 814 | | | 815 | 1 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 816 | 1 | const bool formatted = [&]() { | 817 | 1 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | 1 | return TimeValue::to_format_string_conservative( | 819 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | 1 | datetime_val.nanosecond()); | 821 | 1 | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | 1 | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | 1 | return TimeValue::to_format_string_conservative( | 824 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | 1 | TimeValue::microsecond(time) * 1000); | 826 | 1 | } else { | 827 | 1 | return TimeValue::to_format_string_conservative( | 828 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | 1 | } | 830 | 1 | }(); | 831 | 1 | if (!formatted) { | 832 | 0 | null_map_data[i] = 1; | 833 | 0 | res_offsets.push_back(res_chars.size()); | 834 | 0 | continue; | 835 | 0 | } | 836 | 1 | res_chars.insert(buf, buf + strlen(buf)); | 837 | 1 | res_offsets.push_back(res_chars.size()); | 838 | 1 | } | 839 | 1 | block.replace_by_position(result, | 840 | 1 | ColumnNullable::create(std::move(res_col), std::move(null_map))); | 841 | 1 | return Status::OK(); | 842 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 790 | 1 | uint32_t result, size_t input_rows_count) const override { | 791 | 1 | auto res_col = ColumnString::create(); | 792 | 1 | ColumnString::Chars& res_chars = res_col->get_chars(); | 793 | 1 | ColumnString::Offsets& res_offsets = res_col->get_offsets(); | 794 | | | 795 | 1 | auto null_map = ColumnUInt8::create(); | 796 | 1 | auto& null_map_data = null_map->get_data(); | 797 | 1 | null_map_data.resize_fill(input_rows_count, 0); | 798 | | | 799 | 1 | res_offsets.reserve(input_rows_count); | 800 | | | 801 | 1 | ColumnPtr arg_col[2]; | 802 | 1 | bool is_const[2]; | 803 | 3 | for (size_t i = 0; i < 2; ++i) { | 804 | 2 | const ColumnPtr& col = block.get_by_position(arguments[i]).column; | 805 | 2 | std::tie(arg_col[i], is_const[i]) = unpack_if_const(col); | 806 | 2 | } | 807 | | | 808 | 1 | const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get()); | 809 | 1 | const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get()); | 810 | 2 | for (size_t i = 0; i < input_rows_count; ++i) { | 811 | 1 | const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0])); | 812 | 1 | StringRef format = format_col->get_data_at(index_check_const(i, is_const[1])); | 813 | 1 | TimeValue::TimeType time = get_time_value(datetime_val); | 814 | | | 815 | 1 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 816 | 1 | const bool formatted = [&]() { | 817 | 1 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | 1 | return TimeValue::to_format_string_conservative( | 819 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | 1 | datetime_val.nanosecond()); | 821 | 1 | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | 1 | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | 1 | return TimeValue::to_format_string_conservative( | 824 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | 1 | TimeValue::microsecond(time) * 1000); | 826 | 1 | } else { | 827 | 1 | return TimeValue::to_format_string_conservative( | 828 | 1 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | 1 | } | 830 | 1 | }(); | 831 | 1 | if (!formatted) { | 832 | 0 | null_map_data[i] = 1; | 833 | 0 | res_offsets.push_back(res_chars.size()); | 834 | 0 | continue; | 835 | 0 | } | 836 | 1 | res_chars.insert(buf, buf + strlen(buf)); | 837 | 1 | res_offsets.push_back(res_chars.size()); | 838 | 1 | } | 839 | 1 | block.replace_by_position(result, | 840 | 1 | ColumnNullable::create(std::move(res_col), std::move(null_map))); | 841 | 1 | return Status::OK(); | 842 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjm Line | Count | Source | 790 | 3 | uint32_t result, size_t input_rows_count) const override { | 791 | 3 | auto res_col = ColumnString::create(); | 792 | 3 | ColumnString::Chars& res_chars = res_col->get_chars(); | 793 | 3 | ColumnString::Offsets& res_offsets = res_col->get_offsets(); | 794 | | | 795 | 3 | auto null_map = ColumnUInt8::create(); | 796 | 3 | auto& null_map_data = null_map->get_data(); | 797 | 3 | null_map_data.resize_fill(input_rows_count, 0); | 798 | | | 799 | 3 | res_offsets.reserve(input_rows_count); | 800 | | | 801 | 3 | ColumnPtr arg_col[2]; | 802 | 3 | bool is_const[2]; | 803 | 9 | for (size_t i = 0; i < 2; ++i) { | 804 | 6 | const ColumnPtr& col = block.get_by_position(arguments[i]).column; | 805 | 6 | std::tie(arg_col[i], is_const[i]) = unpack_if_const(col); | 806 | 6 | } | 807 | | | 808 | 3 | const auto* datetime_col = assert_cast<const ArgColType*>(arg_col[0].get()); | 809 | 3 | const auto* format_col = assert_cast<const ColumnString*>(arg_col[1].get()); | 810 | 6 | for (size_t i = 0; i < input_rows_count; ++i) { | 811 | 3 | const auto& datetime_val = datetime_col->get_element(index_check_const(i, is_const[0])); | 812 | 3 | StringRef format = format_col->get_data_at(index_check_const(i, is_const[1])); | 813 | 3 | TimeValue::TimeType time = get_time_value(datetime_val); | 814 | | | 815 | 3 | char buf[100 + SAFE_FORMAT_STRING_MARGIN]; | 816 | 3 | const bool formatted = [&]() { | 817 | 3 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 818 | 3 | return TimeValue::to_format_string_conservative( | 819 | 3 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 820 | 3 | datetime_val.nanosecond()); | 821 | 3 | } else if constexpr (ArgPType == PrimitiveType::TYPE_DATETIMEV2 || | 822 | 3 | ArgPType == PrimitiveType::TYPE_TIMEV2) { | 823 | 3 | return TimeValue::to_format_string_conservative( | 824 | 3 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time, | 825 | 3 | TimeValue::microsecond(time) * 1000); | 826 | 3 | } else { | 827 | 3 | return TimeValue::to_format_string_conservative( | 828 | 3 | format.data, format.size, buf, 100 + SAFE_FORMAT_STRING_MARGIN, time); | 829 | 3 | } | 830 | 3 | }(); | 831 | 3 | if (!formatted) { | 832 | 0 | null_map_data[i] = 1; | 833 | 0 | res_offsets.push_back(res_chars.size()); | 834 | 0 | continue; | 835 | 0 | } | 836 | 3 | res_chars.insert(buf, buf + strlen(buf)); | 837 | 3 | res_offsets.push_back(res_chars.size()); | 838 | 3 | } | 839 | 3 | block.replace_by_position(result, | 840 | 3 | ColumnNullable::create(std::move(res_col), std::move(null_map))); | 841 | 3 | return Status::OK(); | 842 | 3 | } |
|
843 | | |
844 | | private: |
845 | 5 | TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const { |
846 | 5 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) { |
847 | 3 | return static_cast<TimeValue::TimeType>(datetime_val); |
848 | 3 | } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { |
849 | 1 | return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond()); |
850 | 1 | } else { |
851 | 1 | return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(), |
852 | 1 | datetime_val.second(), datetime_val.microsecond()); |
853 | 1 | } |
854 | 5 | } Unexecuted instantiation: _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE25EE14get_time_valueERKNS_11DateV2ValueINS_15DateV2ValueTypeEEE _ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE26EE14get_time_valueERKNS_11DateV2ValueINS_19DateTimeV2ValueTypeEEE Line | Count | Source | 845 | 1 | TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const { | 846 | | if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) { | 847 | | return static_cast<TimeValue::TimeType>(datetime_val); | 848 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 849 | | return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond()); | 850 | 1 | } else { | 851 | 1 | return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(), | 852 | 1 | datetime_val.second(), datetime_val.microsecond()); | 853 | 1 | } | 854 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE43EE14get_time_valueERKNS_16TimeStampNsValueE Line | Count | Source | 845 | 1 | TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const { | 846 | | if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) { | 847 | | return static_cast<TimeValue::TimeType>(datetime_val); | 848 | 1 | } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 849 | 1 | return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond()); | 850 | | } else { | 851 | | return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(), | 852 | | datetime_val.second(), datetime_val.microsecond()); | 853 | | } | 854 | 1 | } |
_ZNK5doris18FunctionTimeFormatILNS_13PrimitiveTypeE27EE14get_time_valueERKd Line | Count | Source | 845 | 3 | TimeValue::TimeType get_time_value(const ArgCppType& datetime_val) const { | 846 | 3 | if constexpr (ArgPType == PrimitiveType::TYPE_TIMEV2) { | 847 | 3 | return static_cast<TimeValue::TimeType>(datetime_val); | 848 | | } else if constexpr (ArgPType == PrimitiveType::TYPE_TIMESTAMP_NS) { | 849 | | return static_cast<TimeValue::TimeType>(datetime_val.time_part_to_microsecond()); | 850 | | } else { | 851 | | return TimeValue::make_time(datetime_val.hour(), datetime_val.minute(), | 852 | | datetime_val.second(), datetime_val.microsecond()); | 853 | | } | 854 | 3 | } |
|
855 | | }; |
856 | | |
857 | | } // namespace doris |
858 | | |
859 | | #if defined(__GNUC__) && (__GNUC__ >= 15) |
860 | | #pragma GCC diagnostic pop |
861 | | #endif |