Coverage Report

Created: 2026-03-16 05:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/cast_to_date.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <sys/types.h>
21
22
#include <cstdint>
23
#include <cstdlib>
24
#include <type_traits>
25
26
#include "common/status.h"
27
#include "core/binary_cast.hpp"
28
#include "core/column/column_nullable.h"
29
#include "core/data_type/data_type_date_or_datetime_v2.h"
30
#include "core/data_type/data_type_date_time.h"
31
#include "core/data_type/data_type_decimal.h" // IWYU pragma: keep
32
#include "core/data_type/data_type_number.h"
33
#include "core/data_type/data_type_string.h"
34
#include "core/data_type/data_type_time.h"
35
#include "core/data_type/primitive_type.h"
36
#include "core/data_type_serde/data_type_serde.h"
37
#include "core/types.h"
38
#include "core/value/time_value.h"
39
#include "core/value/vdatetime_value.h"
40
#include "exprs/function/cast/cast_base.h"
41
#include "exprs/function/cast/cast_to_datetimev2_impl.hpp"
42
#include "runtime/runtime_state.h"
43
44
namespace doris {
45
#include "common/compile_check_begin.h"
46
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
47
    requires(IsStringType<FromDataType> && IsDatelikeTypes<ToDataType>)
48
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
49
public:
50
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
51
                        uint32_t result, size_t input_rows_count,
52
113
                        const NullMap::value_type* null_map = nullptr) const override {
53
113
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
113
                block.get_by_position(arguments[0]).column.get());
55
56
113
        auto to_type = block.get_by_position(result).type;
57
113
        auto serde = remove_nullable(to_type)->get_serde();
58
59
113
        DataTypeSerDe::FormatOptions options;
60
113
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
113
        MutableColumnPtr column_to = to_type->create_column();
64
113
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
113
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
113
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
107
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
107
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
107
        } else {
72
            // may write nulls to nullable_col_to
73
6
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
6
        }
75
76
9
        block.get_by_position(result).column = std::move(nullable_col_to);
77
113
        return Status::OK();
78
113
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
48
                        const NullMap::value_type* null_map = nullptr) const override {
53
48
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
48
                block.get_by_position(arguments[0]).column.get());
55
56
48
        auto to_type = block.get_by_position(result).type;
57
48
        auto serde = remove_nullable(to_type)->get_serde();
58
59
48
        DataTypeSerDe::FormatOptions options;
60
48
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
48
        MutableColumnPtr column_to = to_type->create_column();
64
48
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
48
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
48
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
48
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
48
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
        } else {
72
            // may write nulls to nullable_col_to
73
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
        }
75
76
1
        block.get_by_position(result).column = std::move(nullable_col_to);
77
48
        return Status::OK();
78
48
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
3
                        const NullMap::value_type* null_map = nullptr) const override {
53
3
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
3
                block.get_by_position(arguments[0]).column.get());
55
56
3
        auto to_type = block.get_by_position(result).type;
57
3
        auto serde = remove_nullable(to_type)->get_serde();
58
59
3
        DataTypeSerDe::FormatOptions options;
60
3
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
3
        MutableColumnPtr column_to = to_type->create_column();
64
3
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
3
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
3
        } else {
72
            // may write nulls to nullable_col_to
73
3
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
3
        }
75
76
3
        block.get_by_position(result).column = std::move(nullable_col_to);
77
3
        return Status::OK();
78
3
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
48
                        const NullMap::value_type* null_map = nullptr) const override {
53
48
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
48
                block.get_by_position(arguments[0]).column.get());
55
56
48
        auto to_type = block.get_by_position(result).type;
57
48
        auto serde = remove_nullable(to_type)->get_serde();
58
59
48
        DataTypeSerDe::FormatOptions options;
60
48
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
48
        MutableColumnPtr column_to = to_type->create_column();
64
48
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
48
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
48
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
48
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
48
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
        } else {
72
            // may write nulls to nullable_col_to
73
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
        }
75
76
1
        block.get_by_position(result).column = std::move(nullable_col_to);
77
48
        return Status::OK();
78
48
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
2
                        const NullMap::value_type* null_map = nullptr) const override {
53
2
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
2
                block.get_by_position(arguments[0]).column.get());
55
56
2
        auto to_type = block.get_by_position(result).type;
57
2
        auto serde = remove_nullable(to_type)->get_serde();
58
59
2
        DataTypeSerDe::FormatOptions options;
60
2
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
2
        MutableColumnPtr column_to = to_type->create_column();
64
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
2
        } else {
72
            // may write nulls to nullable_col_to
73
2
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
2
        }
75
76
2
        block.get_by_position(result).column = std::move(nullable_col_to);
77
2
        return Status::OK();
78
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
11
                        const NullMap::value_type* null_map = nullptr) const override {
53
11
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
11
                block.get_by_position(arguments[0]).column.get());
55
56
11
        auto to_type = block.get_by_position(result).type;
57
11
        auto serde = remove_nullable(to_type)->get_serde();
58
59
11
        DataTypeSerDe::FormatOptions options;
60
11
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
11
        MutableColumnPtr column_to = to_type->create_column();
64
11
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
11
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
11
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
11
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
11
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
        } else {
72
            // may write nulls to nullable_col_to
73
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
        }
75
76
1
        block.get_by_position(result).column = std::move(nullable_col_to);
77
11
        return Status::OK();
78
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
52
1
                        const NullMap::value_type* null_map = nullptr) const override {
53
1
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
54
1
                block.get_by_position(arguments[0]).column.get());
55
56
1
        auto to_type = block.get_by_position(result).type;
57
1
        auto serde = remove_nullable(to_type)->get_serde();
58
59
1
        DataTypeSerDe::FormatOptions options;
60
1
        options.timezone = &context->state()->timezone_obj();
61
62
        // by default framework, to_type is already unwrapped nullable
63
1
        MutableColumnPtr column_to = to_type->create_column();
64
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
65
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
66
67
        if constexpr (CastMode == CastModeType::StrictMode) {
68
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
69
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
70
                    *col_from, nullable_col_to->get_nested_column(), options, null_map));
71
1
        } else {
72
            // may write nulls to nullable_col_to
73
1
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, options));
74
1
        }
75
76
1
        block.get_by_position(result).column = std::move(nullable_col_to);
77
1
        return Status::OK();
78
1
    }
79
};
80
81
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
82
    requires(CastUtil::IsPureDigitType<FromDataType> && IsDatelikeTypes<ToDataType>)
83
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
84
public:
85
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
86
                        uint32_t result, size_t input_rows_count,
87
37
                        const NullMap::value_type* null_map = nullptr) const override {
88
37
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
37
                block.get_by_position(arguments[0]).column.get());
90
37
        auto to_type = block.get_by_position(result).type;
91
37
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
37
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
37
        MutableColumnPtr column_to = to_type->create_column();
96
37
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
37
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
37
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
21
            if constexpr (IsDataTypeInt<FromDataType>) {
104
10
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
10
                        *col_from, nullable_col_to->get_nested_column()));
106
10
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
10
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
10
                        *col_from, nullable_col_to->get_nested_column()));
109
10
            } else {
110
1
                static_assert(IsDataTypeDecimal<FromDataType>);
111
1
                RETURN_IF_ERROR(
112
1
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
1
                                *col_from, nullable_col_to->get_nested_column()));
114
1
            }
115
21
        } else {
116
            // may write nulls to nullable_col_to
117
16
            if constexpr (IsDataTypeInt<FromDataType>) {
118
5
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
5
                        *col_from, *nullable_col_to));
120
5
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
5
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
5
                        *col_from, *nullable_col_to));
123
6
            } else {
124
6
                static_assert(IsDataTypeDecimal<FromDataType>);
125
6
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
6
                        *col_from, *nullable_col_to));
127
6
            }
128
16
        }
129
130
16
        block.get_by_position(result).column = std::move(nullable_col_to);
131
37
        return Status::OK();
132
37
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
5
                        const NullMap::value_type* null_map = nullptr) const override {
88
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
5
                block.get_by_position(arguments[0]).column.get());
90
5
        auto to_type = block.get_by_position(result).type;
91
5
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
5
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
5
        MutableColumnPtr column_to = to_type->create_column();
96
5
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
5
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
5
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
5
            if constexpr (IsDataTypeInt<FromDataType>) {
104
5
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
5
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
        }
129
130
0
        block.get_by_position(result).column = std::move(nullable_col_to);
131
5
        return Status::OK();
132
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
2
                        const NullMap::value_type* null_map = nullptr) const override {
88
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
2
                block.get_by_position(arguments[0]).column.get());
90
2
        auto to_type = block.get_by_position(result).type;
91
2
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
2
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
2
        MutableColumnPtr column_to = to_type->create_column();
96
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
2
        } else {
116
            // may write nulls to nullable_col_to
117
2
            if constexpr (IsDataTypeInt<FromDataType>) {
118
2
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
2
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
2
        }
129
130
2
        block.get_by_position(result).column = std::move(nullable_col_to);
131
2
        return Status::OK();
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
5
                        const NullMap::value_type* null_map = nullptr) const override {
88
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
5
                block.get_by_position(arguments[0]).column.get());
90
5
        auto to_type = block.get_by_position(result).type;
91
5
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
5
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
5
        MutableColumnPtr column_to = to_type->create_column();
96
5
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
5
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
5
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
5
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
5
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
5
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
        }
129
130
0
        block.get_by_position(result).column = std::move(nullable_col_to);
131
5
        return Status::OK();
132
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
2
                        const NullMap::value_type* null_map = nullptr) const override {
88
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
2
                block.get_by_position(arguments[0]).column.get());
90
2
        auto to_type = block.get_by_position(result).type;
91
2
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
2
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
2
        MutableColumnPtr column_to = to_type->create_column();
96
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
2
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
2
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
2
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
2
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
2
        }
129
130
2
        block.get_by_position(result).column = std::move(nullable_col_to);
131
2
        return Status::OK();
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
2
                        const NullMap::value_type* null_map = nullptr) const override {
88
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
2
                block.get_by_position(arguments[0]).column.get());
90
2
        auto to_type = block.get_by_position(result).type;
91
2
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
2
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
2
        MutableColumnPtr column_to = to_type->create_column();
96
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
2
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
2
            } else {
124
2
                static_assert(IsDataTypeDecimal<FromDataType>);
125
2
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
2
                        *col_from, *nullable_col_to));
127
2
            }
128
2
        }
129
130
2
        block.get_by_position(result).column = std::move(nullable_col_to);
131
2
        return Status::OK();
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
5
                        const NullMap::value_type* null_map = nullptr) const override {
88
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
5
                block.get_by_position(arguments[0]).column.get());
90
5
        auto to_type = block.get_by_position(result).type;
91
5
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
5
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
5
        MutableColumnPtr column_to = to_type->create_column();
96
5
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
5
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
5
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
5
            if constexpr (IsDataTypeInt<FromDataType>) {
104
5
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
5
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
        }
129
130
0
        block.get_by_position(result).column = std::move(nullable_col_to);
131
5
        return Status::OK();
132
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
2
                        const NullMap::value_type* null_map = nullptr) const override {
88
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
2
                block.get_by_position(arguments[0]).column.get());
90
2
        auto to_type = block.get_by_position(result).type;
91
2
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
2
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
2
        MutableColumnPtr column_to = to_type->create_column();
96
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
2
        } else {
116
            // may write nulls to nullable_col_to
117
2
            if constexpr (IsDataTypeInt<FromDataType>) {
118
2
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
2
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
2
        }
129
130
2
        block.get_by_position(result).column = std::move(nullable_col_to);
131
2
        return Status::OK();
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
5
                        const NullMap::value_type* null_map = nullptr) const override {
88
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
5
                block.get_by_position(arguments[0]).column.get());
90
5
        auto to_type = block.get_by_position(result).type;
91
5
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
5
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
5
        MutableColumnPtr column_to = to_type->create_column();
96
5
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
5
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
5
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
5
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
5
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
5
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
        }
129
130
0
        block.get_by_position(result).column = std::move(nullable_col_to);
131
5
        return Status::OK();
132
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
2
                        const NullMap::value_type* null_map = nullptr) const override {
88
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
2
                block.get_by_position(arguments[0]).column.get());
90
2
        auto to_type = block.get_by_position(result).type;
91
2
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
2
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
2
        MutableColumnPtr column_to = to_type->create_column();
96
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
2
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
2
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
2
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
2
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
2
        }
129
130
2
        block.get_by_position(result).column = std::move(nullable_col_to);
131
2
        return Status::OK();
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
1
                        const NullMap::value_type* null_map = nullptr) const override {
88
1
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
1
                block.get_by_position(arguments[0]).column.get());
90
1
        auto to_type = block.get_by_position(result).type;
91
1
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
1
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
1
        MutableColumnPtr column_to = to_type->create_column();
96
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
1
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
1
            } else {
110
1
                static_assert(IsDataTypeDecimal<FromDataType>);
111
1
                RETURN_IF_ERROR(
112
1
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
1
                                *col_from, nullable_col_to->get_nested_column()));
114
1
            }
115
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
        }
129
130
0
        block.get_by_position(result).column = std::move(nullable_col_to);
131
1
        return Status::OK();
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
3
                        const NullMap::value_type* null_map = nullptr) const override {
88
3
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
3
                block.get_by_position(arguments[0]).column.get());
90
3
        auto to_type = block.get_by_position(result).type;
91
3
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
3
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
3
        MutableColumnPtr column_to = to_type->create_column();
96
3
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
3
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
3
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
3
            } else {
124
3
                static_assert(IsDataTypeDecimal<FromDataType>);
125
3
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
3
                        *col_from, *nullable_col_to));
127
3
            }
128
3
        }
129
130
3
        block.get_by_position(result).column = std::move(nullable_col_to);
131
3
        return Status::OK();
132
3
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
1
                        const NullMap::value_type* null_map = nullptr) const override {
88
1
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
1
                block.get_by_position(arguments[0]).column.get());
90
1
        auto to_type = block.get_by_position(result).type;
91
1
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
1
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
1
        MutableColumnPtr column_to = to_type->create_column();
96
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
1
        } else {
116
            // may write nulls to nullable_col_to
117
1
            if constexpr (IsDataTypeInt<FromDataType>) {
118
1
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
1
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
1
        }
129
130
1
        block.get_by_position(result).column = std::move(nullable_col_to);
131
1
        return Status::OK();
132
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
1
                        const NullMap::value_type* null_map = nullptr) const override {
88
1
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
1
                block.get_by_position(arguments[0]).column.get());
90
1
        auto to_type = block.get_by_position(result).type;
91
1
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
1
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
1
        MutableColumnPtr column_to = to_type->create_column();
96
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
1
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
1
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
1
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
1
                        *col_from, *nullable_col_to));
123
            } else {
124
                static_assert(IsDataTypeDecimal<FromDataType>);
125
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
                        *col_from, *nullable_col_to));
127
            }
128
1
        }
129
130
1
        block.get_by_position(result).column = std::move(nullable_col_to);
131
1
        return Status::OK();
132
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
87
1
                        const NullMap::value_type* null_map = nullptr) const override {
88
1
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
89
1
                block.get_by_position(arguments[0]).column.get());
90
1
        auto to_type = block.get_by_position(result).type;
91
1
        auto concrete_serde = std::dynamic_pointer_cast<typename ToDataType::SerDeType>(
92
1
                remove_nullable(to_type)->get_serde());
93
94
        // by default framework, to_type is already unwrapped nullable
95
1
        MutableColumnPtr column_to = to_type->create_column();
96
1
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
97
1
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
98
99
        // datelike types serde must have template functions for those types. but because of they need to be
100
        // template functions, so we cannot make them virtual. that's why we assert_cast `serde` before.
101
        if constexpr (CastMode == CastModeType::StrictMode) {
102
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
103
            if constexpr (IsDataTypeInt<FromDataType>) {
104
                RETURN_IF_ERROR(concrete_serde->template from_int_strict_mode_batch<FromDataType>(
105
                        *col_from, nullable_col_to->get_nested_column()));
106
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
107
                RETURN_IF_ERROR(concrete_serde->template from_float_strict_mode_batch<FromDataType>(
108
                        *col_from, nullable_col_to->get_nested_column()));
109
            } else {
110
                static_assert(IsDataTypeDecimal<FromDataType>);
111
                RETURN_IF_ERROR(
112
                        concrete_serde->template from_decimal_strict_mode_batch<FromDataType>(
113
                                *col_from, nullable_col_to->get_nested_column()));
114
            }
115
1
        } else {
116
            // may write nulls to nullable_col_to
117
            if constexpr (IsDataTypeInt<FromDataType>) {
118
                RETURN_IF_ERROR(concrete_serde->template from_int_batch<FromDataType>(
119
                        *col_from, *nullable_col_to));
120
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
121
                RETURN_IF_ERROR(concrete_serde->template from_float_batch<FromDataType>(
122
                        *col_from, *nullable_col_to));
123
1
            } else {
124
1
                static_assert(IsDataTypeDecimal<FromDataType>);
125
1
                RETURN_IF_ERROR(concrete_serde->template from_decimal_batch<FromDataType>(
126
1
                        *col_from, *nullable_col_to));
127
1
            }
128
1
        }
129
130
1
        block.get_by_position(result).column = std::move(nullable_col_to);
131
1
        return Status::OK();
132
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
133
};
134
135
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
136
    requires(IsDatelikeTypes<FromDataType> && IsDatelikeTypes<ToDataType>)
137
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
138
public:
139
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
140
                        uint32_t result, size_t input_rows_count,
141
9
                        const NullMap::value_type* null_map = nullptr) const override {
142
9
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
9
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
9
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
9
                block.get_by_position(arguments[0]).column.get());
147
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
9
        ColumnUInt8::MutablePtr col_nullmap;
149
150
9
        if constexpr (Nullable) {
151
0
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
0
        }
153
154
34
        for (size_t i = 0; i < input_rows_count; ++i) {
155
25
            if (null_map && null_map[i]) {
156
8
                continue;
157
8
            }
158
17
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
0
                auto dtv1 = col_from->get_data()[i];
161
0
                dtv1.cast_to_date();
162
0
                col_to->get_data()[i] =
163
0
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
0
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
0
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
0
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
0
                col_to->get_data()[i] = col_from->get_data()[i];
169
0
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
0
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
0
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
0
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
0
                auto dtmv1 = col_from->get_data()[i];
174
0
                col_to->get_data()[i] =
175
0
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
2
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
2
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
2
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
0
                VecDateTimeValue dtv;
181
0
                dtv.cast_to_date();
182
0
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
0
                                  context->state()->timezone_obj());
184
185
0
                auto time_value = col_from->get_data()[i];
186
0
                int32_t hour = TimeValue::hour(time_value);
187
0
                int32_t minute = TimeValue::minute(time_value);
188
0
                int32_t second = TimeValue::second(time_value);
189
0
                bool neg = TimeValue::sign(time_value) < 0;
190
191
0
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
0
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
0
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
0
                col_to->get_data()[i] = dtv;
196
6
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
6
                DateV2Value<DateV2ValueType> dtv;
198
6
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
6
                                  context->state()->timezone_obj());
200
201
6
                auto time_value = col_from->get_data()[i];
202
6
                int32_t hour = TimeValue::hour(time_value);
203
6
                int32_t minute = TimeValue::minute(time_value);
204
6
                int32_t second = TimeValue::second(time_value);
205
6
                bool neg = TimeValue::sign(time_value) < 0;
206
207
6
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
6
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
6
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
6
                col_to->get_data()[i] = dtv;
212
6
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
0
                col_to->get_data()[i] = col_from->get_data()[i];
215
0
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
0
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
0
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
0
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
0
                auto dtv1 = col_from->get_data()[i];
220
0
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
0
                        dtv1.to_datetime_v2());
222
2
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
2
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
2
                                                     col_to->get_data()[i]);
225
2
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
0
                VecDateTimeValue dtv; // datetime by default
228
0
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
0
                                  context->state()->timezone_obj());
230
0
                dtv.reset_time_part();
231
232
0
                auto time_value = col_from->get_data()[i];
233
0
                int32_t hour = TimeValue::hour(time_value);
234
0
                int32_t minute = TimeValue::minute(time_value);
235
0
                int32_t second = TimeValue::second(time_value);
236
0
                bool neg = TimeValue::sign(time_value) < 0;
237
238
0
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
0
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
0
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
0
                col_to->get_data()[i] = dtv;
243
6
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
6
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
6
                        block.get_by_position(arguments[0]).type.get());
246
6
                auto scale = type->get_scale();
247
248
6
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
6
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
6
                                    context->state()->nano_seconds(),
251
6
                                    context->state()->timezone_obj(), scale);
252
6
                dtmv2.reset_time_part();
253
254
6
                auto time_value = col_from->get_data()[i];
255
6
                int32_t hour = TimeValue::hour(time_value);
256
6
                int32_t minute = TimeValue::minute(time_value);
257
6
                int32_t second = TimeValue::second(time_value);
258
6
                int32_t microsecond = TimeValue::microsecond(time_value);
259
6
                bool neg = TimeValue::sign(time_value) < 0;
260
261
6
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
6
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
6
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
6
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
6
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
6
                col_to->get_data()[i] = dtmv2;
268
6
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
0
                auto dtmv1 = col_from->get_data()[i];
271
0
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
0
                        dtmv1.to_datetime_v2());
273
0
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
0
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
0
                                                      col_to->get_data()[i]);
276
0
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
0
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
0
                        block.get_by_position(arguments[0]).type.get());
279
0
                auto scale = type->get_scale();
280
281
0
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
0
                        block.get_by_position(result).type.get());
283
0
                UInt32 to_scale = to_type->get_scale();
284
285
0
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
0
                                                    col_from->get_data()[i]);
287
0
                if (!success) {
288
0
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
0
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
0
                        auto time_zone = cctz::utc_time_zone();
291
0
                        format_options.timezone = (context && context->state())
292
0
                                                          ? &context->state()->timezone_obj()
293
0
                                                          : &time_zone;
294
0
                        return Status::InvalidArgument(
295
0
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
0
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
0
                                to_type->get_name());
298
0
                    } else {
299
0
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
0
                        col_to->get_data()[i] =
304
0
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
0
                                        MIN_DATETIME_V2);
306
0
                    }
307
0
                }
308
309
0
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
0
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
0
                        block.get_by_position(arguments[0]).type.get());
312
0
                auto scale = type->get_scale();
313
314
0
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
0
                        block.get_by_position(result).type.get());
316
0
                UInt32 to_scale = to_type->get_scale();
317
318
0
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
0
                    col_to->get_data()[i] = col_from->get_data()[i];
321
0
                } else {
322
0
                    double time = col_from->get_data()[i];
323
0
                    auto sign = TimeValue::sign(time);
324
0
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
0
                    uint32_t microseconds = TimeValue::microsecond(time);
328
0
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
0
                    uint32_t remainder = microseconds % divisor;
330
331
0
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
0
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
0
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
0
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
0
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
0
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
0
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
0
                        } else {
344
0
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
0
                        }
346
0
                    } else {
347
                        // truncate
348
0
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
0
                    }
350
0
                    col_to->get_data()[i] = sign * time;
351
0
                }
352
1
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
1
                auto dtmv2 = col_from->get_data()[i];
355
356
1
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
1
                        block.get_by_position(arguments[0]).type.get());
358
1
                auto scale = type->get_scale();
359
1
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
1
                        block.get_by_position(result).type.get());
361
1
                UInt32 to_scale = to_type->get_scale();
362
363
1
                uint32_t hour = dtmv2.hour();
364
1
                uint32_t minute = dtmv2.minute();
365
1
                uint32_t second = dtmv2.second();
366
1
                uint32_t microseconds = dtmv2.microsecond();
367
1
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
1
                    DCHECK(to_scale <= 6)
371
0
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
1
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
1
                    uint32_t remainder = microseconds % divisor;
374
1
                    microseconds = (microseconds / divisor) * divisor;
375
1
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
1
                        microseconds += divisor;
378
1
                    }
379
1
                }
380
381
                // carry on if microseconds >= 1000000
382
1
                if (microseconds >= 1000000) {
383
0
                    microseconds -= 1000000;
384
0
                    second += 1;
385
0
                    if (second >= 60) {
386
0
                        second -= 60;
387
0
                        minute += 1;
388
0
                        if (minute >= 60) {
389
0
                            minute -= 60;
390
0
                            hour += 1;
391
0
                        }
392
0
                    }
393
0
                }
394
395
1
                auto time = TimeValue::limit_with_bound(
396
1
                        TimeValue::make_time(hour, minute, second, microseconds));
397
1
                col_to->get_data()[i] = time;
398
1
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
0
                auto dtmv1 = col_from->get_data()[i];
400
0
                auto time = TimeValue::limit_with_bound(
401
0
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
0
                col_to->get_data()[i] = time;
403
0
            }
404
17
        }
405
406
9
        if constexpr (Nullable) {
407
0
            block.get_by_position(result).column =
408
0
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
9
        } else {
410
9
            block.get_by_position(result).column = std::move(col_to);
411
9
        }
412
9
        return Status::OK();
413
9
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_12DataTypeDateEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_16DataTypeDateTimeEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
141
2
                        const NullMap::value_type* null_map = nullptr) const override {
142
2
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
2
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
2
                block.get_by_position(arguments[0]).column.get());
147
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
2
        ColumnUInt8::MutablePtr col_nullmap;
149
150
        if constexpr (Nullable) {
151
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
        }
153
154
6
        for (size_t i = 0; i < input_rows_count; ++i) {
155
4
            if (null_map && null_map[i]) {
156
2
                continue;
157
2
            }
158
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
                auto dtv1 = col_from->get_data()[i];
161
                dtv1.cast_to_date();
162
                col_to->get_data()[i] =
163
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
                col_to->get_data()[i] = col_from->get_data()[i];
169
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
                auto dtmv1 = col_from->get_data()[i];
174
                col_to->get_data()[i] =
175
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
2
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
2
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
                VecDateTimeValue dtv;
181
                dtv.cast_to_date();
182
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
                                  context->state()->timezone_obj());
184
185
                auto time_value = col_from->get_data()[i];
186
                int32_t hour = TimeValue::hour(time_value);
187
                int32_t minute = TimeValue::minute(time_value);
188
                int32_t second = TimeValue::second(time_value);
189
                bool neg = TimeValue::sign(time_value) < 0;
190
191
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
                col_to->get_data()[i] = dtv;
196
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
                DateV2Value<DateV2ValueType> dtv;
198
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
                                  context->state()->timezone_obj());
200
201
                auto time_value = col_from->get_data()[i];
202
                int32_t hour = TimeValue::hour(time_value);
203
                int32_t minute = TimeValue::minute(time_value);
204
                int32_t second = TimeValue::second(time_value);
205
                bool neg = TimeValue::sign(time_value) < 0;
206
207
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
                col_to->get_data()[i] = dtv;
212
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
                col_to->get_data()[i] = col_from->get_data()[i];
215
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
                auto dtv1 = col_from->get_data()[i];
220
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
                        dtv1.to_datetime_v2());
222
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
                                                     col_to->get_data()[i]);
225
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
                VecDateTimeValue dtv; // datetime by default
228
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
                                  context->state()->timezone_obj());
230
                dtv.reset_time_part();
231
232
                auto time_value = col_from->get_data()[i];
233
                int32_t hour = TimeValue::hour(time_value);
234
                int32_t minute = TimeValue::minute(time_value);
235
                int32_t second = TimeValue::second(time_value);
236
                bool neg = TimeValue::sign(time_value) < 0;
237
238
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
                col_to->get_data()[i] = dtv;
243
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
                        block.get_by_position(arguments[0]).type.get());
246
                auto scale = type->get_scale();
247
248
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
                                    context->state()->nano_seconds(),
251
                                    context->state()->timezone_obj(), scale);
252
                dtmv2.reset_time_part();
253
254
                auto time_value = col_from->get_data()[i];
255
                int32_t hour = TimeValue::hour(time_value);
256
                int32_t minute = TimeValue::minute(time_value);
257
                int32_t second = TimeValue::second(time_value);
258
                int32_t microsecond = TimeValue::microsecond(time_value);
259
                bool neg = TimeValue::sign(time_value) < 0;
260
261
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
                col_to->get_data()[i] = dtmv2;
268
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
                auto dtmv1 = col_from->get_data()[i];
271
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
                        dtmv1.to_datetime_v2());
273
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
                                                      col_to->get_data()[i]);
276
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
                        block.get_by_position(arguments[0]).type.get());
279
                auto scale = type->get_scale();
280
281
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
                        block.get_by_position(result).type.get());
283
                UInt32 to_scale = to_type->get_scale();
284
285
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
                                                    col_from->get_data()[i]);
287
                if (!success) {
288
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
                        auto time_zone = cctz::utc_time_zone();
291
                        format_options.timezone = (context && context->state())
292
                                                          ? &context->state()->timezone_obj()
293
                                                          : &time_zone;
294
                        return Status::InvalidArgument(
295
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
                                to_type->get_name());
298
                    } else {
299
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
                        col_to->get_data()[i] =
304
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
                                        MIN_DATETIME_V2);
306
                    }
307
                }
308
309
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
                        block.get_by_position(arguments[0]).type.get());
312
                auto scale = type->get_scale();
313
314
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
                        block.get_by_position(result).type.get());
316
                UInt32 to_scale = to_type->get_scale();
317
318
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
                    col_to->get_data()[i] = col_from->get_data()[i];
321
                } else {
322
                    double time = col_from->get_data()[i];
323
                    auto sign = TimeValue::sign(time);
324
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
                    uint32_t microseconds = TimeValue::microsecond(time);
328
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
                    uint32_t remainder = microseconds % divisor;
330
331
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
                        } else {
344
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
                        }
346
                    } else {
347
                        // truncate
348
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
                    }
350
                    col_to->get_data()[i] = sign * time;
351
                }
352
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
                auto dtmv2 = col_from->get_data()[i];
355
356
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
                        block.get_by_position(arguments[0]).type.get());
358
                auto scale = type->get_scale();
359
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
                        block.get_by_position(result).type.get());
361
                UInt32 to_scale = to_type->get_scale();
362
363
                uint32_t hour = dtmv2.hour();
364
                uint32_t minute = dtmv2.minute();
365
                uint32_t second = dtmv2.second();
366
                uint32_t microseconds = dtmv2.microsecond();
367
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
                    DCHECK(to_scale <= 6)
371
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
                    uint32_t remainder = microseconds % divisor;
374
                    microseconds = (microseconds / divisor) * divisor;
375
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
                        microseconds += divisor;
378
                    }
379
                }
380
381
                // carry on if microseconds >= 1000000
382
                if (microseconds >= 1000000) {
383
                    microseconds -= 1000000;
384
                    second += 1;
385
                    if (second >= 60) {
386
                        second -= 60;
387
                        minute += 1;
388
                        if (minute >= 60) {
389
                            minute -= 60;
390
                            hour += 1;
391
                        }
392
                    }
393
                }
394
395
                auto time = TimeValue::limit_with_bound(
396
                        TimeValue::make_time(hour, minute, second, microseconds));
397
                col_to->get_data()[i] = time;
398
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
                auto dtmv1 = col_from->get_data()[i];
400
                auto time = TimeValue::limit_with_bound(
401
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
                col_to->get_data()[i] = time;
403
            }
404
2
        }
405
406
        if constexpr (Nullable) {
407
            block.get_by_position(result).column =
408
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
2
        } else {
410
2
            block.get_by_position(result).column = std::move(col_to);
411
2
        }
412
2
        return Status::OK();
413
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeDateV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
141
2
                        const NullMap::value_type* null_map = nullptr) const override {
142
2
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
2
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
2
                block.get_by_position(arguments[0]).column.get());
147
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
2
        ColumnUInt8::MutablePtr col_nullmap;
149
150
        if constexpr (Nullable) {
151
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
        }
153
154
10
        for (size_t i = 0; i < input_rows_count; ++i) {
155
8
            if (null_map && null_map[i]) {
156
2
                continue;
157
2
            }
158
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
                auto dtv1 = col_from->get_data()[i];
161
                dtv1.cast_to_date();
162
                col_to->get_data()[i] =
163
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
                col_to->get_data()[i] = col_from->get_data()[i];
169
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
                auto dtmv1 = col_from->get_data()[i];
174
                col_to->get_data()[i] =
175
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
                VecDateTimeValue dtv;
181
                dtv.cast_to_date();
182
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
                                  context->state()->timezone_obj());
184
185
                auto time_value = col_from->get_data()[i];
186
                int32_t hour = TimeValue::hour(time_value);
187
                int32_t minute = TimeValue::minute(time_value);
188
                int32_t second = TimeValue::second(time_value);
189
                bool neg = TimeValue::sign(time_value) < 0;
190
191
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
                col_to->get_data()[i] = dtv;
196
6
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
6
                DateV2Value<DateV2ValueType> dtv;
198
6
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
6
                                  context->state()->timezone_obj());
200
201
6
                auto time_value = col_from->get_data()[i];
202
6
                int32_t hour = TimeValue::hour(time_value);
203
6
                int32_t minute = TimeValue::minute(time_value);
204
6
                int32_t second = TimeValue::second(time_value);
205
6
                bool neg = TimeValue::sign(time_value) < 0;
206
207
6
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
6
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
6
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
6
                col_to->get_data()[i] = dtv;
212
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
                col_to->get_data()[i] = col_from->get_data()[i];
215
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
                auto dtv1 = col_from->get_data()[i];
220
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
                        dtv1.to_datetime_v2());
222
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
                                                     col_to->get_data()[i]);
225
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
                VecDateTimeValue dtv; // datetime by default
228
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
                                  context->state()->timezone_obj());
230
                dtv.reset_time_part();
231
232
                auto time_value = col_from->get_data()[i];
233
                int32_t hour = TimeValue::hour(time_value);
234
                int32_t minute = TimeValue::minute(time_value);
235
                int32_t second = TimeValue::second(time_value);
236
                bool neg = TimeValue::sign(time_value) < 0;
237
238
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
                col_to->get_data()[i] = dtv;
243
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
                        block.get_by_position(arguments[0]).type.get());
246
                auto scale = type->get_scale();
247
248
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
                                    context->state()->nano_seconds(),
251
                                    context->state()->timezone_obj(), scale);
252
                dtmv2.reset_time_part();
253
254
                auto time_value = col_from->get_data()[i];
255
                int32_t hour = TimeValue::hour(time_value);
256
                int32_t minute = TimeValue::minute(time_value);
257
                int32_t second = TimeValue::second(time_value);
258
                int32_t microsecond = TimeValue::microsecond(time_value);
259
                bool neg = TimeValue::sign(time_value) < 0;
260
261
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
                col_to->get_data()[i] = dtmv2;
268
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
                auto dtmv1 = col_from->get_data()[i];
271
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
                        dtmv1.to_datetime_v2());
273
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
                                                      col_to->get_data()[i]);
276
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
                        block.get_by_position(arguments[0]).type.get());
279
                auto scale = type->get_scale();
280
281
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
                        block.get_by_position(result).type.get());
283
                UInt32 to_scale = to_type->get_scale();
284
285
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
                                                    col_from->get_data()[i]);
287
                if (!success) {
288
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
                        auto time_zone = cctz::utc_time_zone();
291
                        format_options.timezone = (context && context->state())
292
                                                          ? &context->state()->timezone_obj()
293
                                                          : &time_zone;
294
                        return Status::InvalidArgument(
295
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
                                to_type->get_name());
298
                    } else {
299
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
                        col_to->get_data()[i] =
304
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
                                        MIN_DATETIME_V2);
306
                    }
307
                }
308
309
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
                        block.get_by_position(arguments[0]).type.get());
312
                auto scale = type->get_scale();
313
314
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
                        block.get_by_position(result).type.get());
316
                UInt32 to_scale = to_type->get_scale();
317
318
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
                    col_to->get_data()[i] = col_from->get_data()[i];
321
                } else {
322
                    double time = col_from->get_data()[i];
323
                    auto sign = TimeValue::sign(time);
324
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
                    uint32_t microseconds = TimeValue::microsecond(time);
328
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
                    uint32_t remainder = microseconds % divisor;
330
331
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
                        } else {
344
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
                        }
346
                    } else {
347
                        // truncate
348
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
                    }
350
                    col_to->get_data()[i] = sign * time;
351
                }
352
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
                auto dtmv2 = col_from->get_data()[i];
355
356
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
                        block.get_by_position(arguments[0]).type.get());
358
                auto scale = type->get_scale();
359
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
                        block.get_by_position(result).type.get());
361
                UInt32 to_scale = to_type->get_scale();
362
363
                uint32_t hour = dtmv2.hour();
364
                uint32_t minute = dtmv2.minute();
365
                uint32_t second = dtmv2.second();
366
                uint32_t microseconds = dtmv2.microsecond();
367
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
                    DCHECK(to_scale <= 6)
371
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
                    uint32_t remainder = microseconds % divisor;
374
                    microseconds = (microseconds / divisor) * divisor;
375
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
                        microseconds += divisor;
378
                    }
379
                }
380
381
                // carry on if microseconds >= 1000000
382
                if (microseconds >= 1000000) {
383
                    microseconds -= 1000000;
384
                    second += 1;
385
                    if (second >= 60) {
386
                        second -= 60;
387
                        minute += 1;
388
                        if (minute >= 60) {
389
                            minute -= 60;
390
                            hour += 1;
391
                        }
392
                    }
393
                }
394
395
                auto time = TimeValue::limit_with_bound(
396
                        TimeValue::make_time(hour, minute, second, microseconds));
397
                col_to->get_data()[i] = time;
398
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
                auto dtmv1 = col_from->get_data()[i];
400
                auto time = TimeValue::limit_with_bound(
401
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
                col_to->get_data()[i] = time;
403
            }
404
6
        }
405
406
        if constexpr (Nullable) {
407
            block.get_by_position(result).column =
408
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
2
        } else {
410
2
            block.get_by_position(result).column = std::move(col_to);
411
2
        }
412
2
        return Status::OK();
413
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
141
2
                        const NullMap::value_type* null_map = nullptr) const override {
142
2
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
2
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
2
                block.get_by_position(arguments[0]).column.get());
147
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
2
        ColumnUInt8::MutablePtr col_nullmap;
149
150
        if constexpr (Nullable) {
151
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
        }
153
154
6
        for (size_t i = 0; i < input_rows_count; ++i) {
155
4
            if (null_map && null_map[i]) {
156
2
                continue;
157
2
            }
158
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
                auto dtv1 = col_from->get_data()[i];
161
                dtv1.cast_to_date();
162
                col_to->get_data()[i] =
163
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
                col_to->get_data()[i] = col_from->get_data()[i];
169
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
                auto dtmv1 = col_from->get_data()[i];
174
                col_to->get_data()[i] =
175
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
                VecDateTimeValue dtv;
181
                dtv.cast_to_date();
182
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
                                  context->state()->timezone_obj());
184
185
                auto time_value = col_from->get_data()[i];
186
                int32_t hour = TimeValue::hour(time_value);
187
                int32_t minute = TimeValue::minute(time_value);
188
                int32_t second = TimeValue::second(time_value);
189
                bool neg = TimeValue::sign(time_value) < 0;
190
191
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
                col_to->get_data()[i] = dtv;
196
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
                DateV2Value<DateV2ValueType> dtv;
198
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
                                  context->state()->timezone_obj());
200
201
                auto time_value = col_from->get_data()[i];
202
                int32_t hour = TimeValue::hour(time_value);
203
                int32_t minute = TimeValue::minute(time_value);
204
                int32_t second = TimeValue::second(time_value);
205
                bool neg = TimeValue::sign(time_value) < 0;
206
207
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
                col_to->get_data()[i] = dtv;
212
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
                col_to->get_data()[i] = col_from->get_data()[i];
215
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
                auto dtv1 = col_from->get_data()[i];
220
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
                        dtv1.to_datetime_v2());
222
2
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
2
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
2
                                                     col_to->get_data()[i]);
225
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
                VecDateTimeValue dtv; // datetime by default
228
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
                                  context->state()->timezone_obj());
230
                dtv.reset_time_part();
231
232
                auto time_value = col_from->get_data()[i];
233
                int32_t hour = TimeValue::hour(time_value);
234
                int32_t minute = TimeValue::minute(time_value);
235
                int32_t second = TimeValue::second(time_value);
236
                bool neg = TimeValue::sign(time_value) < 0;
237
238
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
                col_to->get_data()[i] = dtv;
243
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
                        block.get_by_position(arguments[0]).type.get());
246
                auto scale = type->get_scale();
247
248
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
                                    context->state()->nano_seconds(),
251
                                    context->state()->timezone_obj(), scale);
252
                dtmv2.reset_time_part();
253
254
                auto time_value = col_from->get_data()[i];
255
                int32_t hour = TimeValue::hour(time_value);
256
                int32_t minute = TimeValue::minute(time_value);
257
                int32_t second = TimeValue::second(time_value);
258
                int32_t microsecond = TimeValue::microsecond(time_value);
259
                bool neg = TimeValue::sign(time_value) < 0;
260
261
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
                col_to->get_data()[i] = dtmv2;
268
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
                auto dtmv1 = col_from->get_data()[i];
271
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
                        dtmv1.to_datetime_v2());
273
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
                                                      col_to->get_data()[i]);
276
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
                        block.get_by_position(arguments[0]).type.get());
279
                auto scale = type->get_scale();
280
281
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
                        block.get_by_position(result).type.get());
283
                UInt32 to_scale = to_type->get_scale();
284
285
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
                                                    col_from->get_data()[i]);
287
                if (!success) {
288
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
                        auto time_zone = cctz::utc_time_zone();
291
                        format_options.timezone = (context && context->state())
292
                                                          ? &context->state()->timezone_obj()
293
                                                          : &time_zone;
294
                        return Status::InvalidArgument(
295
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
                                to_type->get_name());
298
                    } else {
299
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
                        col_to->get_data()[i] =
304
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
                                        MIN_DATETIME_V2);
306
                    }
307
                }
308
309
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
                        block.get_by_position(arguments[0]).type.get());
312
                auto scale = type->get_scale();
313
314
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
                        block.get_by_position(result).type.get());
316
                UInt32 to_scale = to_type->get_scale();
317
318
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
                    col_to->get_data()[i] = col_from->get_data()[i];
321
                } else {
322
                    double time = col_from->get_data()[i];
323
                    auto sign = TimeValue::sign(time);
324
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
                    uint32_t microseconds = TimeValue::microsecond(time);
328
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
                    uint32_t remainder = microseconds % divisor;
330
331
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
                        } else {
344
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
                        }
346
                    } else {
347
                        // truncate
348
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
                    }
350
                    col_to->get_data()[i] = sign * time;
351
                }
352
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
                auto dtmv2 = col_from->get_data()[i];
355
356
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
                        block.get_by_position(arguments[0]).type.get());
358
                auto scale = type->get_scale();
359
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
                        block.get_by_position(result).type.get());
361
                UInt32 to_scale = to_type->get_scale();
362
363
                uint32_t hour = dtmv2.hour();
364
                uint32_t minute = dtmv2.minute();
365
                uint32_t second = dtmv2.second();
366
                uint32_t microseconds = dtmv2.microsecond();
367
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
                    DCHECK(to_scale <= 6)
371
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
                    uint32_t remainder = microseconds % divisor;
374
                    microseconds = (microseconds / divisor) * divisor;
375
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
                        microseconds += divisor;
378
                    }
379
                }
380
381
                // carry on if microseconds >= 1000000
382
                if (microseconds >= 1000000) {
383
                    microseconds -= 1000000;
384
                    second += 1;
385
                    if (second >= 60) {
386
                        second -= 60;
387
                        minute += 1;
388
                        if (minute >= 60) {
389
                            minute -= 60;
390
                            hour += 1;
391
                        }
392
                    }
393
                }
394
395
                auto time = TimeValue::limit_with_bound(
396
                        TimeValue::make_time(hour, minute, second, microseconds));
397
                col_to->get_data()[i] = time;
398
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
                auto dtmv1 = col_from->get_data()[i];
400
                auto time = TimeValue::limit_with_bound(
401
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
                col_to->get_data()[i] = time;
403
            }
404
2
        }
405
406
        if constexpr (Nullable) {
407
            block.get_by_position(result).column =
408
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
2
        } else {
410
2
            block.get_by_position(result).column = std::move(col_to);
411
2
        }
412
2
        return Status::OK();
413
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_18DataTypeDateTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
141
2
                        const NullMap::value_type* null_map = nullptr) const override {
142
2
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
2
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
2
                block.get_by_position(arguments[0]).column.get());
147
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
2
        ColumnUInt8::MutablePtr col_nullmap;
149
150
        if constexpr (Nullable) {
151
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
        }
153
154
10
        for (size_t i = 0; i < input_rows_count; ++i) {
155
8
            if (null_map && null_map[i]) {
156
2
                continue;
157
2
            }
158
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
                auto dtv1 = col_from->get_data()[i];
161
                dtv1.cast_to_date();
162
                col_to->get_data()[i] =
163
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
                col_to->get_data()[i] = col_from->get_data()[i];
169
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
                auto dtmv1 = col_from->get_data()[i];
174
                col_to->get_data()[i] =
175
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
                VecDateTimeValue dtv;
181
                dtv.cast_to_date();
182
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
                                  context->state()->timezone_obj());
184
185
                auto time_value = col_from->get_data()[i];
186
                int32_t hour = TimeValue::hour(time_value);
187
                int32_t minute = TimeValue::minute(time_value);
188
                int32_t second = TimeValue::second(time_value);
189
                bool neg = TimeValue::sign(time_value) < 0;
190
191
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
                col_to->get_data()[i] = dtv;
196
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
                DateV2Value<DateV2ValueType> dtv;
198
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
                                  context->state()->timezone_obj());
200
201
                auto time_value = col_from->get_data()[i];
202
                int32_t hour = TimeValue::hour(time_value);
203
                int32_t minute = TimeValue::minute(time_value);
204
                int32_t second = TimeValue::second(time_value);
205
                bool neg = TimeValue::sign(time_value) < 0;
206
207
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
                col_to->get_data()[i] = dtv;
212
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
                col_to->get_data()[i] = col_from->get_data()[i];
215
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
                auto dtv1 = col_from->get_data()[i];
220
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
                        dtv1.to_datetime_v2());
222
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
                                                     col_to->get_data()[i]);
225
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
                VecDateTimeValue dtv; // datetime by default
228
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
                                  context->state()->timezone_obj());
230
                dtv.reset_time_part();
231
232
                auto time_value = col_from->get_data()[i];
233
                int32_t hour = TimeValue::hour(time_value);
234
                int32_t minute = TimeValue::minute(time_value);
235
                int32_t second = TimeValue::second(time_value);
236
                bool neg = TimeValue::sign(time_value) < 0;
237
238
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
                col_to->get_data()[i] = dtv;
243
6
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
6
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
6
                        block.get_by_position(arguments[0]).type.get());
246
6
                auto scale = type->get_scale();
247
248
6
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
6
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
6
                                    context->state()->nano_seconds(),
251
6
                                    context->state()->timezone_obj(), scale);
252
6
                dtmv2.reset_time_part();
253
254
6
                auto time_value = col_from->get_data()[i];
255
6
                int32_t hour = TimeValue::hour(time_value);
256
6
                int32_t minute = TimeValue::minute(time_value);
257
6
                int32_t second = TimeValue::second(time_value);
258
6
                int32_t microsecond = TimeValue::microsecond(time_value);
259
6
                bool neg = TimeValue::sign(time_value) < 0;
260
261
6
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
6
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
6
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
6
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
6
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
6
                col_to->get_data()[i] = dtmv2;
268
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
                auto dtmv1 = col_from->get_data()[i];
271
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
                        dtmv1.to_datetime_v2());
273
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
                                                      col_to->get_data()[i]);
276
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
                        block.get_by_position(arguments[0]).type.get());
279
                auto scale = type->get_scale();
280
281
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
                        block.get_by_position(result).type.get());
283
                UInt32 to_scale = to_type->get_scale();
284
285
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
                                                    col_from->get_data()[i]);
287
                if (!success) {
288
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
                        auto time_zone = cctz::utc_time_zone();
291
                        format_options.timezone = (context && context->state())
292
                                                          ? &context->state()->timezone_obj()
293
                                                          : &time_zone;
294
                        return Status::InvalidArgument(
295
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
                                to_type->get_name());
298
                    } else {
299
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
                        col_to->get_data()[i] =
304
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
                                        MIN_DATETIME_V2);
306
                    }
307
                }
308
309
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
                        block.get_by_position(arguments[0]).type.get());
312
                auto scale = type->get_scale();
313
314
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
                        block.get_by_position(result).type.get());
316
                UInt32 to_scale = to_type->get_scale();
317
318
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
                    col_to->get_data()[i] = col_from->get_data()[i];
321
                } else {
322
                    double time = col_from->get_data()[i];
323
                    auto sign = TimeValue::sign(time);
324
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
                    uint32_t microseconds = TimeValue::microsecond(time);
328
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
                    uint32_t remainder = microseconds % divisor;
330
331
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
                        } else {
344
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
                        }
346
                    } else {
347
                        // truncate
348
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
                    }
350
                    col_to->get_data()[i] = sign * time;
351
                }
352
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
                auto dtmv2 = col_from->get_data()[i];
355
356
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
                        block.get_by_position(arguments[0]).type.get());
358
                auto scale = type->get_scale();
359
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
                        block.get_by_position(result).type.get());
361
                UInt32 to_scale = to_type->get_scale();
362
363
                uint32_t hour = dtmv2.hour();
364
                uint32_t minute = dtmv2.minute();
365
                uint32_t second = dtmv2.second();
366
                uint32_t microseconds = dtmv2.microsecond();
367
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
                    DCHECK(to_scale <= 6)
371
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
                    uint32_t remainder = microseconds % divisor;
374
                    microseconds = (microseconds / divisor) * divisor;
375
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
                        microseconds += divisor;
378
                    }
379
                }
380
381
                // carry on if microseconds >= 1000000
382
                if (microseconds >= 1000000) {
383
                    microseconds -= 1000000;
384
                    second += 1;
385
                    if (second >= 60) {
386
                        second -= 60;
387
                        minute += 1;
388
                        if (minute >= 60) {
389
                            minute -= 60;
390
                            hour += 1;
391
                        }
392
                    }
393
                }
394
395
                auto time = TimeValue::limit_with_bound(
396
                        TimeValue::make_time(hour, minute, second, microseconds));
397
                col_to->get_data()[i] = time;
398
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
                auto dtmv1 = col_from->get_data()[i];
400
                auto time = TimeValue::limit_with_bound(
401
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
                col_to->get_data()[i] = time;
403
            }
404
6
        }
405
406
        if constexpr (Nullable) {
407
            block.get_by_position(result).column =
408
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
2
        } else {
410
2
            block.get_by_position(result).column = std::move(col_to);
411
2
        }
412
2
        return Status::OK();
413
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
141
1
                        const NullMap::value_type* null_map = nullptr) const override {
142
1
        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
143
1
                                  (IsTimeV2Type<FromDataType> || IsDateTimeV2Type<FromDataType>);
144
145
1
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
146
1
                block.get_by_position(arguments[0]).column.get());
147
1
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
148
1
        ColumnUInt8::MutablePtr col_nullmap;
149
150
        if constexpr (Nullable) {
151
            col_nullmap = ColumnUInt8::create(input_rows_count, 0);
152
        }
153
154
2
        for (size_t i = 0; i < input_rows_count; ++i) {
155
1
            if (null_map && null_map[i]) {
156
0
                continue;
157
0
            }
158
            if constexpr (IsDateType<FromDataType> && IsDateV2Type<ToDataType>) {
159
                // from Date to Date
160
                auto dtv1 = col_from->get_data()[i];
161
                dtv1.cast_to_date();
162
                col_to->get_data()[i] =
163
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtv1.to_date_v2());
164
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateType<ToDataType>) {
165
                DataTypeDateV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
166
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateType<ToDataType>) {
167
                // from Datetime to Date
168
                col_to->get_data()[i] = col_from->get_data()[i];
169
                DataTypeDate::cast_to_date(col_to->get_data()[i]);
170
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
171
                DataTypeDateTimeV2::cast_to_date(col_from->get_data()[i], col_to->get_data()[i]);
172
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateV2Type<ToDataType>) {
173
                auto dtmv1 = col_from->get_data()[i];
174
                col_to->get_data()[i] =
175
                        binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(dtmv1.to_date_v2());
176
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
177
                DataTypeDateTimeV2::cast_to_date_v2(col_from->get_data()[i], col_to->get_data()[i]);
178
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateType<ToDataType>) {
179
                // from Time to Date
180
                VecDateTimeValue dtv;
181
                dtv.cast_to_date();
182
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
183
                                  context->state()->timezone_obj());
184
185
                auto time_value = col_from->get_data()[i];
186
                int32_t hour = TimeValue::hour(time_value);
187
                int32_t minute = TimeValue::minute(time_value);
188
                int32_t second = TimeValue::second(time_value);
189
                bool neg = TimeValue::sign(time_value) < 0;
190
191
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
192
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
193
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
194
195
                col_to->get_data()[i] = dtv;
196
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateV2Type<ToDataType>) {
197
                DateV2Value<DateV2ValueType> dtv;
198
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
199
                                  context->state()->timezone_obj());
200
201
                auto time_value = col_from->get_data()[i];
202
                int32_t hour = TimeValue::hour(time_value);
203
                int32_t minute = TimeValue::minute(time_value);
204
                int32_t second = TimeValue::second(time_value);
205
                bool neg = TimeValue::sign(time_value) < 0;
206
207
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
208
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
209
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
210
211
                col_to->get_data()[i] = dtv;
212
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeType<ToDataType>) {
213
                // from Date to Datetime
214
                col_to->get_data()[i] = col_from->get_data()[i];
215
                DataTypeDateTime::cast_to_date_time(col_to->get_data()[i]);
216
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
217
                DataTypeDateV2::cast_to_date_time(col_from->get_data()[i], col_to->get_data()[i]);
218
            } else if constexpr (IsDateType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
219
                auto dtv1 = col_from->get_data()[i];
220
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
221
                        dtv1.to_datetime_v2());
222
            } else if constexpr (IsDateV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
223
                DataTypeDateV2::cast_to_date_time_v2(col_from->get_data()[i],
224
                                                     col_to->get_data()[i]);
225
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
226
                // from Time to Datetime
227
                VecDateTimeValue dtv; // datetime by default
228
                dtv.from_unixtime(context->state()->timestamp_ms() / 1000,
229
                                  context->state()->timezone_obj());
230
                dtv.reset_time_part();
231
232
                auto time_value = col_from->get_data()[i];
233
                int32_t hour = TimeValue::hour(time_value);
234
                int32_t minute = TimeValue::minute(time_value);
235
                int32_t second = TimeValue::second(time_value);
236
                bool neg = TimeValue::sign(time_value) < 0;
237
238
                dtv.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
239
                dtv.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
240
                dtv.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
241
242
                col_to->get_data()[i] = dtv;
243
            } else if constexpr (IsTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
244
                const auto* type = assert_cast<const DataTypeTimeV2*>(
245
                        block.get_by_position(arguments[0]).type.get());
246
                auto scale = type->get_scale();
247
248
                DateV2Value<DateTimeV2ValueType> dtmv2;
249
                dtmv2.from_unixtime(context->state()->timestamp_ms() / 1000,
250
                                    context->state()->nano_seconds(),
251
                                    context->state()->timezone_obj(), scale);
252
                dtmv2.reset_time_part();
253
254
                auto time_value = col_from->get_data()[i];
255
                int32_t hour = TimeValue::hour(time_value);
256
                int32_t minute = TimeValue::minute(time_value);
257
                int32_t second = TimeValue::second(time_value);
258
                int32_t microsecond = TimeValue::microsecond(time_value);
259
                bool neg = TimeValue::sign(time_value) < 0;
260
261
                dtmv2.date_add_interval<TimeUnit::HOUR, false>(TimeInterval(HOUR, hour, neg));
262
                dtmv2.date_add_interval<TimeUnit::MINUTE, false>(TimeInterval(MINUTE, minute, neg));
263
                dtmv2.date_add_interval<TimeUnit::SECOND, false>(TimeInterval(SECOND, second, neg));
264
                dtmv2.date_add_interval<TimeUnit::MICROSECOND, false>(
265
                        TimeInterval(MICROSECOND, microsecond, neg));
266
267
                col_to->get_data()[i] = dtmv2;
268
            } else if constexpr (IsDateTimeType<FromDataType> && IsDateTimeV2Type<ToDataType>) {
269
                // from Datetime to Datetime
270
                auto dtmv1 = col_from->get_data()[i];
271
                col_to->get_data()[i] = binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
272
                        dtmv1.to_datetime_v2());
273
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeType<ToDataType>) {
274
                DataTypeDateTimeV2::cast_to_date_time(col_from->get_data()[i],
275
                                                      col_to->get_data()[i]);
276
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsDateTimeV2Type<ToDataType>) {
277
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
278
                        block.get_by_position(arguments[0]).type.get());
279
                auto scale = type->get_scale();
280
281
                const auto* to_type = assert_cast<const DataTypeDateTimeV2*>(
282
                        block.get_by_position(result).type.get());
283
                UInt32 to_scale = to_type->get_scale();
284
285
                bool success = transform_date_scale(to_scale, scale, col_to->get_data()[i],
286
                                                    col_from->get_data()[i]);
287
                if (!success) {
288
                    if constexpr (CastMode == CastModeType::StrictMode) {
289
                        auto format_options = DataTypeSerDe::get_default_format_options();
290
                        auto time_zone = cctz::utc_time_zone();
291
                        format_options.timezone = (context && context->state())
292
                                                          ? &context->state()->timezone_obj()
293
                                                          : &time_zone;
294
                        return Status::InvalidArgument(
295
                                "DatetimeV2 overflow when casting {} from {} to {}",
296
                                type->to_string(*col_from, i, format_options), type->get_name(),
297
                                to_type->get_name());
298
                    } else {
299
                        col_nullmap->get_data()[i] = true;
300
                        //TODO: maybe we can remove all set operations on nested of null cell.
301
                        // the correctness should be keep by downstream user with replace_... or manually
302
                        // process null data if need.
303
                        col_to->get_data()[i] =
304
                                binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(
305
                                        MIN_DATETIME_V2);
306
                    }
307
                }
308
309
            } else if constexpr (IsTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
310
                const auto* type = assert_cast<const DataTypeTimeV2*>(
311
                        block.get_by_position(arguments[0]).type.get());
312
                auto scale = type->get_scale();
313
314
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
315
                        block.get_by_position(result).type.get());
316
                UInt32 to_scale = to_type->get_scale();
317
318
                if (to_scale >= scale) {
319
                    // nothing to do, just copy
320
                    col_to->get_data()[i] = col_from->get_data()[i];
321
                } else {
322
                    double time = col_from->get_data()[i];
323
                    auto sign = TimeValue::sign(time);
324
                    time = std::abs(time);
325
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
326
                    // 999956: 56 > 100/2, then round up to 1000000
327
                    uint32_t microseconds = TimeValue::microsecond(time);
328
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
329
                    uint32_t remainder = microseconds % divisor;
330
331
                    if (remainder >= divisor / 2) { // need to round up
332
                        // do rounding up
333
                        uint32_t rounded_microseconds = ((microseconds / divisor) + 1) * divisor;
334
                        // need carry on
335
                        if (rounded_microseconds >= TimeValue::ONE_SECOND_MICROSECONDS) {
336
                            DCHECK(rounded_microseconds == TimeValue::ONE_SECOND_MICROSECONDS);
337
                            time = ((int64_t)time / TimeValue::ONE_SECOND_MICROSECONDS + 1) *
338
                                   TimeValue::ONE_SECOND_MICROSECONDS;
339
340
                            // the input data must be valid, so max to '838:59:59.0'. this value won't carry on
341
                            // to second.
342
                            DCHECK(TimeValue::valid(time)) << col_from->get_data()[i];
343
                        } else {
344
                            time = TimeValue::reset_microsecond(time, rounded_microseconds);
345
                        }
346
                    } else {
347
                        // truncate
348
                        time = TimeValue::reset_microsecond(time, microseconds / divisor * divisor);
349
                    }
350
                    col_to->get_data()[i] = sign * time;
351
                }
352
1
            } else if constexpr (IsDateTimeV2Type<FromDataType> && IsTimeV2Type<ToDataType>) {
353
                // from Datetime to Time
354
1
                auto dtmv2 = col_from->get_data()[i];
355
356
1
                const auto* type = assert_cast<const DataTypeDateTimeV2*>(
357
1
                        block.get_by_position(arguments[0]).type.get());
358
1
                auto scale = type->get_scale();
359
1
                const auto* to_type = assert_cast<const DataTypeTimeV2*>(
360
1
                        block.get_by_position(result).type.get());
361
1
                UInt32 to_scale = to_type->get_scale();
362
363
1
                uint32_t hour = dtmv2.hour();
364
1
                uint32_t minute = dtmv2.minute();
365
1
                uint32_t second = dtmv2.second();
366
1
                uint32_t microseconds = dtmv2.microsecond();
367
1
                if (to_scale < scale) { // need to round
368
                    // e.g. scale reduce to 4, means we need to round the last 2 digits
369
                    // 999956: 56 > 100/2, then round up to 1000000
370
1
                    DCHECK(to_scale <= 6)
371
0
                            << "to_scale should be in range [0, 6], but got " << to_scale;
372
1
                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
373
1
                    uint32_t remainder = microseconds % divisor;
374
1
                    microseconds = (microseconds / divisor) * divisor;
375
1
                    if (remainder >= divisor / 2) {
376
                        // do rounding up
377
1
                        microseconds += divisor;
378
1
                    }
379
1
                }
380
381
                // carry on if microseconds >= 1000000
382
1
                if (microseconds >= 1000000) {
383
0
                    microseconds -= 1000000;
384
0
                    second += 1;
385
0
                    if (second >= 60) {
386
0
                        second -= 60;
387
0
                        minute += 1;
388
0
                        if (minute >= 60) {
389
0
                            minute -= 60;
390
0
                            hour += 1;
391
0
                        }
392
0
                    }
393
0
                }
394
395
1
                auto time = TimeValue::limit_with_bound(
396
1
                        TimeValue::make_time(hour, minute, second, microseconds));
397
1
                col_to->get_data()[i] = time;
398
            } else if constexpr (IsDateTimeType<FromDataType> && IsTimeV2Type<ToDataType>) {
399
                auto dtmv1 = col_from->get_data()[i];
400
                auto time = TimeValue::limit_with_bound(
401
                        TimeValue::make_time(dtmv1.hour(), dtmv1.minute(), dtmv1.second()));
402
                col_to->get_data()[i] = time;
403
            }
404
1
        }
405
406
        if constexpr (Nullable) {
407
            block.get_by_position(result).column =
408
                    ColumnNullable::create(std::move(col_to), std::move(col_nullmap));
409
1
        } else {
410
1
            block.get_by_position(result).column = std::move(col_to);
411
1
        }
412
1
        return Status::OK();
413
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeTimeV2EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ES2_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
414
};
415
416
template <>
417
class CastToImpl<CastModeType::StrictMode, DataTypeTimeStampTz, DataTypeDateTimeV2>
418
        : public CastToBase {
419
public:
420
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
421
                        uint32_t result, size_t input_rows_count,
422
2
                        const NullMap::value_type* null_map = nullptr) const override {
423
2
        const auto& col_from =
424
2
                assert_cast<const ColumnTimeStampTz&>(*block.get_by_position(arguments[0]).column)
425
2
                        .get_data();
426
427
2
        auto col_to = ColumnDateTimeV2::create(input_rows_count);
428
2
        auto& col_to_data = col_to->get_data();
429
2
        const auto& local_time_zone = context->state()->timezone_obj();
430
431
2
        const auto tz_scale = block.get_by_position(arguments[0]).type->get_scale();
432
2
        const auto dt_scale = block.get_by_position(result).type->get_scale();
433
434
9
        for (int i = 0; i < input_rows_count; ++i) {
435
8
            if (null_map && null_map[i]) {
436
0
                continue;
437
0
            }
438
8
            TimestampTzValue from_tz {col_from[i]};
439
8
            DateV2Value<DateTimeV2ValueType> dt;
440
8
            if (!from_tz.to_datetime(dt, local_time_zone, dt_scale, tz_scale)) {
441
1
                return Status::InternalError(
442
1
                        "can not cast from  timestamptz : {} to datetime in timezone : {}",
443
1
                        from_tz.to_string(local_time_zone), context->state()->timezone());
444
1
            }
445
7
            col_to_data[i] = dt.to_date_int_val();
446
7
        }
447
448
1
        block.get_by_position(result).column = std::move(col_to);
449
1
        return Status::OK();
450
2
    }
451
};
452
453
template <>
454
class CastToImpl<CastModeType::NonStrictMode, DataTypeTimeStampTz, DataTypeDateTimeV2>
455
        : public CastToBase {
456
public:
457
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
458
                        uint32_t result, size_t input_rows_count,
459
2
                        const NullMap::value_type*) const override {
460
2
        const auto& col_from =
461
2
                assert_cast<const ColumnTimeStampTz&>(*block.get_by_position(arguments[0]).column)
462
2
                        .get_data();
463
464
2
        auto col_to = ColumnDateTimeV2::create(input_rows_count);
465
2
        auto& col_to_data = col_to->get_data();
466
2
        auto col_null = ColumnBool::create(input_rows_count, 0);
467
2
        auto& col_null_map = col_null->get_data();
468
2
        const auto& local_time_zone = context->state()->timezone_obj();
469
470
2
        const auto tz_scale = block.get_by_position(arguments[0]).type->get_scale();
471
2
        const auto dt_scale = block.get_by_position(result).type->get_scale();
472
473
10
        for (int i = 0; i < input_rows_count; ++i) {
474
8
            TimestampTzValue from_tz {col_from[i]};
475
8
            DateV2Value<DateTimeV2ValueType> dt;
476
8
            if (from_tz.to_datetime(dt, local_time_zone, dt_scale, tz_scale)) {
477
7
                col_to_data[i] = dt;
478
7
            } else {
479
1
                col_null_map[i] = 1;
480
1
                col_to_data[i] = MIN_DATETIME_V2;
481
1
            }
482
8
        }
483
2
        block.get_by_position(result).column =
484
2
                ColumnNullable::create(std::move(col_to), std::move(col_null));
485
2
        return Status::OK();
486
2
    }
487
};
488
489
namespace CastWrapper {
490
491
template <typename ToDataType> // must datelike type
492
159
WrapperType create_datelike_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
493
159
    std::shared_ptr<CastToBase> cast_to_datelike;
494
495
159
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
159
        using Types = std::decay_t<decltype(types)>;
497
159
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
159
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
159
            if (context->enable_strict_mode()) {
502
128
                cast_to_datelike = std::make_shared<
503
128
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
128
            } else {
505
31
                cast_to_datelike = std::make_shared<
506
31
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
31
            }
508
159
            return true;
509
159
        } else {
510
0
            return false;
511
0
        }
512
159
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairIS2_vEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairIS2_vEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSQ_
Line
Count
Source
495
7
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
7
        using Types = std::decay_t<decltype(types)>;
497
7
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
7
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
7
            if (context->enable_strict_mode()) {
502
5
                cast_to_datelike = std::make_shared<
503
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
5
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
7
            return true;
509
        } else {
510
            return false;
511
        }
512
7
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSQ_
Line
Count
Source
495
7
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
7
        using Types = std::decay_t<decltype(types)>;
497
7
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
7
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
7
            if (context->enable_strict_mode()) {
502
5
                cast_to_datelike = std::make_shared<
503
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
5
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
7
            return true;
509
        } else {
510
            return false;
511
        }
512
7
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSQ_
Line
Count
Source
495
2
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
2
        using Types = std::decay_t<decltype(types)>;
497
2
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
2
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
2
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
2
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
2
            return true;
509
        } else {
510
            return false;
511
        }
512
2
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairIS2_vEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSQ_
Line
Count
Source
495
2
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
2
        using Types = std::decay_t<decltype(types)>;
497
2
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
2
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
2
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
2
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
2
            return true;
509
        } else {
510
            return false;
511
        }
512
2
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSQ_
Line
Count
Source
495
2
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
2
        using Types = std::decay_t<decltype(types)>;
497
2
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
2
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
2
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
2
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
2
            return true;
509
        } else {
510
            return false;
511
        }
512
2
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSQ_
Line
Count
Source
495
51
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
51
        using Types = std::decay_t<decltype(types)>;
497
51
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
51
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
51
            if (context->enable_strict_mode()) {
502
48
                cast_to_datelike = std::make_shared<
503
48
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
48
            } else {
505
3
                cast_to_datelike = std::make_shared<
506
3
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
3
            }
508
51
            return true;
509
        } else {
510
            return false;
511
        }
512
51
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSQ_
Line
Count
Source
495
7
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
7
        using Types = std::decay_t<decltype(types)>;
497
7
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
7
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
7
            if (context->enable_strict_mode()) {
502
5
                cast_to_datelike = std::make_shared<
503
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
5
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
7
            return true;
509
        } else {
510
            return false;
511
        }
512
7
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSQ_
Line
Count
Source
495
7
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
7
        using Types = std::decay_t<decltype(types)>;
497
7
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
7
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
7
            if (context->enable_strict_mode()) {
502
5
                cast_to_datelike = std::make_shared<
503
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
5
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
7
            return true;
509
        } else {
510
            return false;
511
        }
512
7
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSQ_
Line
Count
Source
495
4
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
4
        using Types = std::decay_t<decltype(types)>;
497
4
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
4
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
4
            if (context->enable_strict_mode()) {
502
1
                cast_to_datelike = std::make_shared<
503
1
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
3
            } else {
505
3
                cast_to_datelike = std::make_shared<
506
3
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
3
            }
508
4
            return true;
509
        } else {
510
            return false;
511
        }
512
4
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSQ_
Line
Count
Source
495
2
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
2
        using Types = std::decay_t<decltype(types)>;
497
2
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
2
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
2
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
2
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
2
            return true;
509
        } else {
510
            return false;
511
        }
512
2
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairIS2_vEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSQ_
Line
Count
Source
495
2
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
2
        using Types = std::decay_t<decltype(types)>;
497
2
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
2
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
2
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
2
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
2
            return true;
509
        } else {
510
            return false;
511
        }
512
2
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSQ_
Line
Count
Source
495
50
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
50
        using Types = std::decay_t<decltype(types)>;
497
50
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
50
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
50
            if (context->enable_strict_mode()) {
502
48
                cast_to_datelike = std::make_shared<
503
48
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
48
            } else {
505
2
                cast_to_datelike = std::make_shared<
506
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
2
            }
508
50
            return true;
509
        } else {
510
            return false;
511
        }
512
50
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSQ_
Line
Count
Source
495
1
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
1
        using Types = std::decay_t<decltype(types)>;
497
1
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
1
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
1
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
1
            } else {
505
1
                cast_to_datelike = std::make_shared<
506
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
1
            }
508
1
            return true;
509
        } else {
510
            return false;
511
        }
512
1
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSQ_
Line
Count
Source
495
1
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
1
        using Types = std::decay_t<decltype(types)>;
497
1
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
1
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
1
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
1
            } else {
505
1
                cast_to_datelike = std::make_shared<
506
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
1
            }
508
1
            return true;
509
        } else {
510
            return false;
511
        }
512
1
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSQ_
Line
Count
Source
495
1
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
1
        using Types = std::decay_t<decltype(types)>;
497
1
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
1
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
1
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
1
            } else {
505
1
                cast_to_datelike = std::make_shared<
506
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
1
            }
508
1
            return true;
509
        } else {
510
            return false;
511
        }
512
1
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSQ_
Line
Count
Source
495
1
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
1
        using Types = std::decay_t<decltype(types)>;
497
1
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
1
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
1
            if (context->enable_strict_mode()) {
502
0
                cast_to_datelike = std::make_shared<
503
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
1
            } else {
505
1
                cast_to_datelike = std::make_shared<
506
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
1
            }
508
1
            return true;
509
        } else {
510
            return false;
511
        }
512
1
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairIS2_vEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv4EvEEEEbSQ_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_12DataTypeIPv6EvEEEEbSQ_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKT_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSQ_
Line
Count
Source
495
12
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
12
        using Types = std::decay_t<decltype(types)>;
497
12
        using FromDataType = typename Types::LeftType;
498
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
                      IsStringType<FromDataType> ||
500
12
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
12
            if (context->enable_strict_mode()) {
502
11
                cast_to_datelike = std::make_shared<
503
11
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
11
            } else {
505
1
                cast_to_datelike = std::make_shared<
506
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
1
            }
508
12
            return true;
509
        } else {
510
            return false;
511
        }
512
12
    };
513
514
159
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(),
515
159
                                           make_datelike_wrapper)) {
516
0
        return create_unsupport_wrapper(fmt::format(
517
0
                "CAST AS {} not supported {}", ToDataType {}.get_name(), from_type->get_name()));
518
0
    }
519
520
159
    return [cast_to_datelike](FunctionContext* context, Block& block,
521
159
                              const ColumnNumbers& arguments, const uint32_t result,
522
159
                              size_t input_rows_count,
523
159
                              const NullMap::value_type* null_map = nullptr) {
524
159
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
159
                                              null_map);
526
159
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS6_S8_SD_jmSF_E_clES6_S8_SD_jmSF_
Unexecuted instantiation: _ZZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS6_S8_SD_jmSF_E_clES6_S8_SD_jmSF_
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS6_S8_SD_jmSF_E_clES6_S8_SD_jmSF_
Line
Count
Source
523
71
                              const NullMap::value_type* null_map = nullptr) {
524
71
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
71
                                              null_map);
526
71
    };
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS6_S8_SD_jmSF_E_clES6_S8_SD_jmSF_
Line
Count
Source
523
72
                              const NullMap::value_type* null_map = nullptr) {
524
72
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
72
                                              null_map);
526
72
    };
_ZZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS6_S8_SD_jmSF_E_clES6_S8_SD_jmSF_
Line
Count
Source
523
16
                              const NullMap::value_type* null_map = nullptr) {
524
16
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
16
                                              null_map);
526
16
    };
527
159
}
Unexecuted instantiation: _ZN5doris11CastWrapper23create_datelike_wrapperINS_12DataTypeDateEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEE
Unexecuted instantiation: _ZN5doris11CastWrapper23create_datelike_wrapperINS_16DataTypeDateTimeEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEE
_ZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeDateV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
492
71
WrapperType create_datelike_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
493
71
    std::shared_ptr<CastToBase> cast_to_datelike;
494
495
71
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
71
        using Types = std::decay_t<decltype(types)>;
497
71
        using FromDataType = typename Types::LeftType;
498
71
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
71
                      IsStringType<FromDataType> ||
500
71
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
71
            if (context->enable_strict_mode()) {
502
71
                cast_to_datelike = std::make_shared<
503
71
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
71
            } else {
505
71
                cast_to_datelike = std::make_shared<
506
71
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
71
            }
508
71
            return true;
509
71
        } else {
510
71
            return false;
511
71
        }
512
71
    };
513
514
71
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(),
515
71
                                           make_datelike_wrapper)) {
516
0
        return create_unsupport_wrapper(fmt::format(
517
0
                "CAST AS {} not supported {}", ToDataType {}.get_name(), from_type->get_name()));
518
0
    }
519
520
71
    return [cast_to_datelike](FunctionContext* context, Block& block,
521
71
                              const ColumnNumbers& arguments, const uint32_t result,
522
71
                              size_t input_rows_count,
523
71
                              const NullMap::value_type* null_map = nullptr) {
524
71
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
71
                                              null_map);
526
71
    };
527
71
}
_ZN5doris11CastWrapper23create_datelike_wrapperINS_18DataTypeDateTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
492
72
WrapperType create_datelike_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
493
72
    std::shared_ptr<CastToBase> cast_to_datelike;
494
495
72
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
72
        using Types = std::decay_t<decltype(types)>;
497
72
        using FromDataType = typename Types::LeftType;
498
72
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
72
                      IsStringType<FromDataType> ||
500
72
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
72
            if (context->enable_strict_mode()) {
502
72
                cast_to_datelike = std::make_shared<
503
72
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
72
            } else {
505
72
                cast_to_datelike = std::make_shared<
506
72
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
72
            }
508
72
            return true;
509
72
        } else {
510
72
            return false;
511
72
        }
512
72
    };
513
514
72
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(),
515
72
                                           make_datelike_wrapper)) {
516
0
        return create_unsupport_wrapper(fmt::format(
517
0
                "CAST AS {} not supported {}", ToDataType {}.get_name(), from_type->get_name()));
518
0
    }
519
520
72
    return [cast_to_datelike](FunctionContext* context, Block& block,
521
72
                              const ColumnNumbers& arguments, const uint32_t result,
522
72
                              size_t input_rows_count,
523
72
                              const NullMap::value_type* null_map = nullptr) {
524
72
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
72
                                              null_map);
526
72
    };
527
72
}
_ZN5doris11CastWrapper23create_datelike_wrapperINS_14DataTypeTimeV2EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES6_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
492
16
WrapperType create_datelike_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
493
16
    std::shared_ptr<CastToBase> cast_to_datelike;
494
495
16
    auto make_datelike_wrapper = [&](const auto& types) -> bool {
496
16
        using Types = std::decay_t<decltype(types)>;
497
16
        using FromDataType = typename Types::LeftType;
498
16
        if constexpr (CastUtil::IsPureDigitType<FromDataType> || IsDatelikeTypes<FromDataType> ||
499
16
                      IsStringType<FromDataType> ||
500
16
                      std::is_same_v<FromDataType, DataTypeTimeStampTz>) {
501
16
            if (context->enable_strict_mode()) {
502
16
                cast_to_datelike = std::make_shared<
503
16
                        CastToImpl<CastModeType::StrictMode, FromDataType, ToDataType>>();
504
16
            } else {
505
16
                cast_to_datelike = std::make_shared<
506
16
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, ToDataType>>();
507
16
            }
508
16
            return true;
509
16
        } else {
510
16
            return false;
511
16
        }
512
16
    };
513
514
16
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(),
515
16
                                           make_datelike_wrapper)) {
516
0
        return create_unsupport_wrapper(fmt::format(
517
0
                "CAST AS {} not supported {}", ToDataType {}.get_name(), from_type->get_name()));
518
0
    }
519
520
16
    return [cast_to_datelike](FunctionContext* context, Block& block,
521
16
                              const ColumnNumbers& arguments, const uint32_t result,
522
16
                              size_t input_rows_count,
523
16
                              const NullMap::value_type* null_map = nullptr) {
524
16
        return cast_to_datelike->execute_impl(context, block, arguments, result, input_rows_count,
525
16
                                              null_map);
526
16
    };
527
16
}
528
#include "common/compile_check_end.h"
529
}; // namespace CastWrapper
530
} // namespace doris