Coverage Report

Created: 2026-07-24 22:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/cast_to_int.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 <type_traits>
21
22
#include "common/status.h"
23
#include "core/data_type/data_type_decimal.h"
24
#include "core/data_type/data_type_number.h"
25
#include "core/data_type/primitive_type.h"
26
#include "exprs/function/cast/cast_to_basic_number_common.h"
27
28
namespace doris {
29
30
// Types that can be cast to int: string, bool, int, float, double, decimal, date, datetime and time.
31
// It's not supported to cast date to tinyint and smallint, because it will definitely overflow.
32
// It's not supported to cast datetime to tinyint and smallint, because it will definitely overflow.
33
// Casting from string and decimal types are handled in `cast_to_basic_number_common.h`.
34
35
// may overflow if:
36
// 1. from wider int to narrower int
37
// 2. from float/double to int
38
// 3. from time to tinyint, smallint and int
39
template <typename FromDataType, typename ToDataType>
40
constexpr bool CastToIntMayOverflow =
41
        (IsDataTypeInt<FromDataType> &&
42
         sizeof(typename FromDataType::FieldType) > sizeof(typename ToDataType::FieldType)) ||
43
        IsDataTypeFloat<FromDataType> ||
44
        (std::is_same_v<FromDataType, DataTypeTimeV2> &&
45
         (std::is_same_v<ToDataType, DataTypeInt32> || std::is_same_v<ToDataType, DataTypeInt16> ||
46
          std::is_same_v<ToDataType, DataTypeInt8>));
47
48
// from number types and timev2 type to integer types which this cast may overflow -> result type is always nullable.
49
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
50
    requires(IsDataTypeInt<ToDataType> &&
51
             (IsDataTypeNumber<FromDataType> || std::is_same_v<FromDataType, DataTypeTimeV2>) &&
52
             CastToIntMayOverflow<FromDataType, ToDataType>)
53
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
54
public:
55
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
56
                        uint32_t result, size_t input_rows_count,
57
2.41k
                        const NullMap::value_type* null_map = nullptr) const override {
58
2.41k
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2.41k
                block.get_by_position(arguments[0]).column.get());
60
2.41k
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
2.41k
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
1.34k
        const auto& vec_from = col_from->get_data();
68
1.34k
        auto& vec_to = col_to->get_data();
69
1.34k
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
1.34k
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
1.34k
        CastParameters params;
73
1.34k
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
32.6k
        for (size_t i = 0; i < input_rows_count; ++i) {
75
28.9k
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
25.2k
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
160
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
80
                        vec_null_map_to[i] = 1;
81
80
                        continue;
82
80
                    } else {
83
80
                        return params.status;
84
80
                    }
85
160
                }
86
25.2k
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
1.79k
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
624
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
312
                        vec_null_map_to[i] = 1;
90
312
                        continue;
91
312
                    } else {
92
312
                        return params.status;
93
312
                    }
94
624
                }
95
1.92k
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
1.92k
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
1.80k
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
904
                        vec_null_map_to[i] = 1;
99
904
                        continue;
100
904
                    } else {
101
904
                        return params.status;
102
904
                    }
103
1.80k
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
28.9k
        }
110
2.35k
        block.get_by_position(result).column =
111
2.35k
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
2.35k
        return Status::OK();
114
1.06k
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
42
                        const NullMap::value_type* null_map = nullptr) const override {
58
42
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
42
                block.get_by_position(arguments[0]).column.get());
60
42
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
42
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
42
        const auto& vec_from = col_from->get_data();
68
42
        auto& vec_to = col_to->get_data();
69
42
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
42
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
42
        CastParameters params;
73
42
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
118
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
76
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
76
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
40
                    } else {
92
40
                        return params.status;
93
40
                    }
94
40
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
76
        }
110
42
        block.get_by_position(result).column =
111
42
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
42
        return Status::OK();
114
42
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
120
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
76
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
76
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
40
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
40
                        vec_null_map_to[i] = 1;
90
40
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
40
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
76
        }
110
44
        block.get_by_position(result).column =
111
44
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
44
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
50
                        const NullMap::value_type* null_map = nullptr) const override {
58
50
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
50
                block.get_by_position(arguments[0]).column.get());
60
50
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
50
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
50
        const auto& vec_from = col_from->get_data();
68
50
        auto& vec_to = col_to->get_data();
69
50
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
50
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
50
        CastParameters params;
73
50
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
134
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
84
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
84
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
48
                    } else {
92
48
                        return params.status;
93
48
                    }
94
48
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
84
        }
110
50
        block.get_by_position(result).column =
111
50
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
50
        return Status::OK();
114
50
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
136
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
84
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
84
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
48
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
48
                        vec_null_map_to[i] = 1;
90
48
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
48
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
84
        }
110
52
        block.get_by_position(result).column =
111
52
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
52
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
320
                        const NullMap::value_type* null_map = nullptr) const override {
58
320
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
320
                block.get_by_position(arguments[0]).column.get());
60
320
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
320
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
320
        const auto& vec_from = col_from->get_data();
68
320
        auto& vec_to = col_to->get_data();
69
320
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
320
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
320
        CastParameters params;
73
320
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
640
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
316
                    } else {
101
316
                        return params.status;
102
316
                    }
103
316
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
320
        block.get_by_position(result).column =
111
320
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
320
        return Status::OK();
114
320
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
320
                        const NullMap::value_type* null_map = nullptr) const override {
58
320
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
320
                block.get_by_position(arguments[0]).column.get());
60
320
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
320
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
320
        const auto& vec_from = col_from->get_data();
68
320
        auto& vec_to = col_to->get_data();
69
320
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
320
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
320
        CastParameters params;
73
320
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
956
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
316
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
316
                        vec_null_map_to[i] = 1;
99
316
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
316
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
636
        block.get_by_position(result).column =
111
636
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
636
        return Status::OK();
114
320
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
38
                        const NullMap::value_type* null_map = nullptr) const override {
58
38
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
38
                block.get_by_position(arguments[0]).column.get());
60
38
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
38
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
38
        const auto& vec_from = col_from->get_data();
68
38
        auto& vec_to = col_to->get_data();
69
38
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
38
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
38
        CastParameters params;
73
38
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
118
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
80
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
80
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
36
                    } else {
92
36
                        return params.status;
93
36
                    }
94
36
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
80
        }
110
38
        block.get_by_position(result).column =
111
38
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
38
        return Status::OK();
114
38
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
120
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
80
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
80
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
36
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
36
                        vec_null_map_to[i] = 1;
90
36
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
36
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
80
        }
110
40
        block.get_by_position(result).column =
111
40
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
40
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
46
                        const NullMap::value_type* null_map = nullptr) const override {
58
46
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
46
                block.get_by_position(arguments[0]).column.get());
60
46
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
46
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
46
        const auto& vec_from = col_from->get_data();
68
46
        auto& vec_to = col_to->get_data();
69
46
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
46
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
46
        CastParameters params;
73
46
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
134
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
88
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
88
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
44
                    } else {
92
44
                        return params.status;
93
44
                    }
94
44
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
88
        }
110
46
        block.get_by_position(result).column =
111
46
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
46
        return Status::OK();
114
46
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
136
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
88
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
88
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
44
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
44
                        vec_null_map_to[i] = 1;
90
44
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
44
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
88
        }
110
48
        block.get_by_position(result).column =
111
48
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
48
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
320
                        const NullMap::value_type* null_map = nullptr) const override {
58
320
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
320
                block.get_by_position(arguments[0]).column.get());
60
320
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
320
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
320
        const auto& vec_from = col_from->get_data();
68
320
        auto& vec_to = col_to->get_data();
69
320
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
320
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
320
        CastParameters params;
73
320
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
640
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
316
                    } else {
101
316
                        return params.status;
102
316
                    }
103
316
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
320
        block.get_by_position(result).column =
111
320
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
320
        return Status::OK();
114
320
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
320
                        const NullMap::value_type* null_map = nullptr) const override {
58
320
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
320
                block.get_by_position(arguments[0]).column.get());
60
320
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
320
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
320
        const auto& vec_from = col_from->get_data();
68
320
        auto& vec_to = col_to->get_data();
69
320
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
320
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
320
        CastParameters params;
73
320
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
956
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
316
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
316
                        vec_null_map_to[i] = 1;
99
316
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
316
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
636
        block.get_by_position(result).column =
111
636
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
636
        return Status::OK();
114
320
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
70
                        const NullMap::value_type* null_map = nullptr) const override {
58
70
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
70
                block.get_by_position(arguments[0]).column.get());
60
70
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
70
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
70
        const auto& vec_from = col_from->get_data();
68
70
        auto& vec_to = col_to->get_data();
69
70
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
70
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
70
        CastParameters params;
73
70
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
24.8k
        for (size_t i = 0; i < input_rows_count; ++i) {
75
24.7k
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
24.7k
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
24.7k
        }
110
78
        block.get_by_position(result).column =
111
78
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
78
        return Status::OK();
114
70
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
30
                        const NullMap::value_type* null_map = nullptr) const override {
58
30
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
30
                block.get_by_position(arguments[0]).column.get());
60
30
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
30
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
30
        const auto& vec_from = col_from->get_data();
68
30
        auto& vec_to = col_to->get_data();
69
30
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
30
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
30
        CastParameters params;
73
30
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
118
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
88
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
88
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
28
                    } else {
92
28
                        return params.status;
93
28
                    }
94
28
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
88
        }
110
30
        block.get_by_position(result).column =
111
30
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
30
        return Status::OK();
114
30
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
120
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
88
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
88
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
28
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
28
                        vec_null_map_to[i] = 1;
90
28
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
28
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
88
        }
110
32
        block.get_by_position(result).column =
111
32
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
32
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
38
                        const NullMap::value_type* null_map = nullptr) const override {
58
38
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
38
                block.get_by_position(arguments[0]).column.get());
60
38
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
38
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
38
        const auto& vec_from = col_from->get_data();
68
38
        auto& vec_to = col_to->get_data();
69
38
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
38
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
38
        CastParameters params;
73
38
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
134
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
96
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
96
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
36
                    } else {
92
36
                        return params.status;
93
36
                    }
94
36
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
96
        }
110
38
        block.get_by_position(result).column =
111
38
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
38
        return Status::OK();
114
38
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
136
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
96
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
96
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
36
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
36
                        vec_null_map_to[i] = 1;
90
36
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
36
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
96
        }
110
40
        block.get_by_position(result).column =
111
40
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
40
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
276
                        const NullMap::value_type* null_map = nullptr) const override {
58
276
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
276
                block.get_by_position(arguments[0]).column.get());
60
276
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
276
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
276
        const auto& vec_from = col_from->get_data();
68
276
        auto& vec_to = col_to->get_data();
69
276
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
276
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
276
        CastParameters params;
73
276
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
596
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
272
                    } else {
101
272
                        return params.status;
102
272
                    }
103
272
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
276
        block.get_by_position(result).column =
111
276
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
276
        return Status::OK();
114
276
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
276
                        const NullMap::value_type* null_map = nullptr) const override {
58
276
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
276
                block.get_by_position(arguments[0]).column.get());
60
276
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
276
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
276
        const auto& vec_from = col_from->get_data();
68
276
        auto& vec_to = col_to->get_data();
69
276
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
276
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
276
        CastParameters params;
73
276
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
868
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
320
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
320
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
272
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
272
                        vec_null_map_to[i] = 1;
99
272
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
272
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
320
        }
110
548
        block.get_by_position(result).column =
111
548
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
548
        return Status::OK();
114
276
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
10
                        const NullMap::value_type* null_map = nullptr) const override {
58
10
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
10
                block.get_by_position(arguments[0]).column.get());
60
10
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
10
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
10
        const auto& vec_from = col_from->get_data();
68
10
        auto& vec_to = col_to->get_data();
69
10
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
10
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
10
        CastParameters params;
73
10
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
36
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
8
                    } else {
83
8
                        return params.status;
84
8
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
10
        block.get_by_position(result).column =
111
10
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
10
        return Status::OK();
114
10
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
38
        for (size_t i = 0; i < input_rows_count; ++i) {
75
26
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
26
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
8
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
8
                        vec_null_map_to[i] = 1;
81
8
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
8
                }
86
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
26
        }
110
12
        block.get_by_position(result).column =
111
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
12
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
22
                        const NullMap::value_type* null_map = nullptr) const override {
58
22
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
22
                block.get_by_position(arguments[0]).column.get());
60
22
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
22
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
22
        const auto& vec_from = col_from->get_data();
68
22
        auto& vec_to = col_to->get_data();
69
22
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
22
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
22
        CastParameters params;
73
22
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
114
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
92
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
92
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
20
                    } else {
92
20
                        return params.status;
93
20
                    }
94
20
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
92
        }
110
22
        block.get_by_position(result).column =
111
22
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
22
        return Status::OK();
114
22
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
116
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
92
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
92
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
20
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
20
                        vec_null_map_to[i] = 1;
90
20
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
20
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
92
        }
110
24
        block.get_by_position(result).column =
111
24
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
24
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
30
                        const NullMap::value_type* null_map = nullptr) const override {
58
30
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
30
                block.get_by_position(arguments[0]).column.get());
60
30
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
30
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
30
        const auto& vec_from = col_from->get_data();
68
30
        auto& vec_to = col_to->get_data();
69
30
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
30
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
30
        CastParameters params;
73
30
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
130
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
100
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
100
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
28
                    } else {
92
28
                        return params.status;
93
28
                    }
94
28
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
100
        }
110
30
        block.get_by_position(result).column =
111
30
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
30
        return Status::OK();
114
30
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
132
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
100
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
100
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
28
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
28
                        vec_null_map_to[i] = 1;
90
28
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
28
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
100
        }
110
32
        block.get_by_position(result).column =
111
32
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
32
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
14
                        const NullMap::value_type* null_map = nullptr) const override {
58
14
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
14
                block.get_by_position(arguments[0]).column.get());
60
14
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
14
        const auto& vec_from = col_from->get_data();
68
14
        auto& vec_to = col_to->get_data();
69
14
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
14
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
14
        CastParameters params;
73
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
106
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
92
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
92
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
12
                    } else {
92
12
                        return params.status;
93
12
                    }
94
12
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
92
        }
110
14
        block.get_by_position(result).column =
111
14
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
14
        return Status::OK();
114
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
108
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
92
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
92
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
12
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
12
                        vec_null_map_to[i] = 1;
90
12
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
12
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
92
        }
110
16
        block.get_by_position(result).column =
111
16
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
16
        return Status::OK();
114
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
22
                        const NullMap::value_type* null_map = nullptr) const override {
58
22
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
22
                block.get_by_position(arguments[0]).column.get());
60
22
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
22
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
22
        const auto& vec_from = col_from->get_data();
68
22
        auto& vec_to = col_to->get_data();
69
22
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
22
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
22
        CastParameters params;
73
22
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
122
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
100
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
100
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
                        vec_null_map_to[i] = 1;
90
                        continue;
91
20
                    } else {
92
20
                        return params.status;
93
20
                    }
94
20
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
100
        }
110
22
        block.get_by_position(result).column =
111
22
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
22
        return Status::OK();
114
22
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
4
                        const NullMap::value_type* null_map = nullptr) const override {
58
4
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
4
                block.get_by_position(arguments[0]).column.get());
60
4
        if (!col_from) {
61
0
            return Status::InternalError(
62
0
                    fmt::format("Column type mismatch: expected {}, got {}",
63
0
                                type_to_string(FromDataType::PType),
64
0
                                block.get_by_position(arguments[0]).column->get_name()));
65
0
        }
66
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
4
        const auto& vec_from = col_from->get_data();
68
4
        auto& vec_to = col_to->get_data();
69
4
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
4
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
4
        CastParameters params;
73
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
124
        for (size_t i = 0; i < input_rows_count; ++i) {
75
            if constexpr (IsDataTypeInt<FromDataType>) {
76
                // although always nullable output, but only set null when overflow in non-strict mode.
77
                // in strict mode, just raise error on overflow.
78
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
                        vec_null_map_to[i] = 1;
81
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
                }
86
100
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
100
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
20
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
20
                        vec_null_map_to[i] = 1;
90
20
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
20
                }
95
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
                        vec_null_map_to[i] = 1;
99
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
                }
104
            } else {
105
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
106
                                                         type_to_string(FromDataType::PType),
107
                                                         type_to_string(ToDataType::PType)));
108
            }
109
100
        }
110
24
        block.get_by_position(result).column =
111
24
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
24
        return Status::OK();
114
4
    }
115
};
116
117
/// cast to int, will not overflow and no nullable output:
118
/// 1. from bool;
119
/// 2. from narrow int to wider int
120
/// 3. from time to bigint and largeint
121
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
122
    requires(IsDataTypeInt<ToDataType> &&
123
             (IsDataTypeNumber<FromDataType> || std::is_same_v<FromDataType, DataTypeTimeV2>) &&
124
             !CastToIntMayOverflow<FromDataType, ToDataType>)
125
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
126
public:
127
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
128
                        uint32_t result, size_t input_rows_count,
129
611
                        const NullMap::value_type* null_map = nullptr) const override {
130
611
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
611
                                                                 input_rows_count);
132
611
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
160
                        const NullMap::value_type* null_map = nullptr) const override {
130
160
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
160
                                                                 input_rows_count);
132
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
8
                        const NullMap::value_type* null_map = nullptr) const override {
130
8
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
8
                                                                 input_rows_count);
132
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
16
                        const NullMap::value_type* null_map = nullptr) const override {
130
16
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
16
                                                                 input_rows_count);
132
16
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
168
                        const NullMap::value_type* null_map = nullptr) const override {
130
168
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
168
                                                                 input_rows_count);
132
168
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
2
                        const NullMap::value_type* null_map = nullptr) const override {
130
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
2
                                                                 input_rows_count);
132
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
185
                        const NullMap::value_type* null_map = nullptr) const override {
130
185
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
185
                                                                 input_rows_count);
132
185
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
4
                        const NullMap::value_type* null_map = nullptr) const override {
130
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
4
                                                                 input_rows_count);
132
4
    }
133
};
134
135
// cast decimal to integer. always use overflow check to decide nullable
136
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
137
    requires(IsDataTypeInt<ToDataType> && IsDataTypeDecimal<FromDataType>)
138
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
139
public:
140
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
141
                        uint32_t result, size_t input_rows_count,
142
760
                        const NullMap::value_type* null_map = nullptr) const override {
143
760
        using ToFieldType = typename ToDataType::FieldType;
144
145
760
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
760
        const auto* col_from =
147
760
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
760
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
760
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
760
        UInt32 from_precision = from_decimal_type.get_precision();
155
760
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
760
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
760
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
760
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
760
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
760
        const auto& vec_from = col_from->get_data();
166
760
        const auto* vec_from_data = vec_from.data();
167
760
        auto& vec_to = col_to->get_data();
168
760
        auto* vec_to_data = vec_to.data();
169
170
760
        ColumnUInt8::MutablePtr col_null_map_to;
171
760
        NullMap::value_type* null_map_data = nullptr;
172
760
        if (overflow_and_nullable) {
173
292
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
292
            null_map_data = col_null_map_to->get_data().data();
175
292
        }
176
177
760
        CastParameters params;
178
760
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
760
        size_t size = vec_from.size();
180
44.9k
        for (size_t i = 0; i < size; i++) {
181
44.2k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
44.2k
                                         typename ToDataType::FieldType>(
183
44.2k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
44.2k
        }
191
192
760
        if (overflow_and_nullable) {
193
292
            block.get_by_position(result).column =
194
292
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
468
        } else {
196
468
            block.get_by_position(result).column = std::move(col_to);
197
468
        }
198
760
        return Status::OK();
199
760
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
604
        for (size_t i = 0; i < size; i++) {
181
590
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
590
                                         typename ToDataType::FieldType>(
183
590
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
590
        }
191
192
14
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
604
        for (size_t i = 0; i < size; i++) {
181
590
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
590
                                         typename ToDataType::FieldType>(
183
590
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
590
        }
191
192
14
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
604
        for (size_t i = 0; i < size; i++) {
181
590
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
590
                                         typename ToDataType::FieldType>(
183
590
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
590
        }
191
192
14
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
604
        for (size_t i = 0; i < size; i++) {
181
590
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
590
                                         typename ToDataType::FieldType>(
183
590
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
590
        }
191
192
14
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.24k
        for (size_t i = 0; i < size; i++) {
181
1.22k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.22k
                                         typename ToDataType::FieldType>(
183
1.22k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.22k
        }
191
192
18
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
12
        } else {
196
12
            block.get_by_position(result).column = std::move(col_to);
197
12
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.24k
        for (size_t i = 0; i < size; i++) {
181
1.22k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.22k
                                         typename ToDataType::FieldType>(
183
1.22k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.22k
        }
191
192
18
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
12
        } else {
196
12
            block.get_by_position(result).column = std::move(col_to);
197
12
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
296
        for (size_t i = 0; i < size; i++) {
181
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
288
                                         typename ToDataType::FieldType>(
183
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
288
        }
191
192
8
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
0
            block.get_by_position(result).column = std::move(col_to);
197
0
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
584
        for (size_t i = 0; i < size; i++) {
181
576
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
576
                                         typename ToDataType::FieldType>(
183
576
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
576
        }
191
192
8
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
584
        for (size_t i = 0; i < size; i++) {
181
576
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
576
                                         typename ToDataType::FieldType>(
183
576
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
576
        }
191
192
8
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.10k
        for (size_t i = 0; i < size; i++) {
181
1.08k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.08k
                                         typename ToDataType::FieldType>(
183
1.08k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.08k
        }
191
192
18
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
10
            block.get_by_position(result).column = std::move(col_to);
197
10
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
8
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
8
            null_map_data = col_null_map_to->get_data().data();
175
8
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.10k
        for (size_t i = 0; i < size; i++) {
181
1.08k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.08k
                                         typename ToDataType::FieldType>(
183
1.08k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.08k
        }
191
192
18
        if (overflow_and_nullable) {
193
8
            block.get_by_position(result).column =
194
8
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
10
            block.get_by_position(result).column = std::move(col_to);
197
10
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
10
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
10
            null_map_data = col_null_map_to->get_data().data();
175
10
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
958
        for (size_t i = 0; i < size; i++) {
181
940
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
940
                                         typename ToDataType::FieldType>(
183
940
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
940
        }
191
192
18
        if (overflow_and_nullable) {
193
10
            block.get_by_position(result).column =
194
10
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
10
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
14
                        const NullMap::value_type* null_map = nullptr) const override {
143
14
        using ToFieldType = typename ToDataType::FieldType;
144
145
14
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
14
        const auto* col_from =
147
14
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
14
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
14
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
14
        UInt32 from_precision = from_decimal_type.get_precision();
155
14
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
14
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
14
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
14
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
14
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
14
        const auto& vec_from = col_from->get_data();
166
14
        const auto* vec_from_data = vec_from.data();
167
14
        auto& vec_to = col_to->get_data();
168
14
        auto* vec_to_data = vec_to.data();
169
170
14
        ColumnUInt8::MutablePtr col_null_map_to;
171
14
        NullMap::value_type* null_map_data = nullptr;
172
14
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
14
        CastParameters params;
178
14
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
14
        size_t size = vec_from.size();
180
910
        for (size_t i = 0; i < size; i++) {
181
896
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
896
                                         typename ToDataType::FieldType>(
183
896
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
896
        }
191
192
14
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
14
        } else {
196
14
            block.get_by_position(result).column = std::move(col_to);
197
14
        }
198
14
        return Status::OK();
199
14
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
584
        for (size_t i = 0; i < size; i++) {
181
576
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
576
                                         typename ToDataType::FieldType>(
183
576
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
576
        }
191
192
8
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
8
                        const NullMap::value_type* null_map = nullptr) const override {
143
8
        using ToFieldType = typename ToDataType::FieldType;
144
145
8
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
8
        const auto* col_from =
147
8
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
8
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
8
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
8
        UInt32 from_precision = from_decimal_type.get_precision();
155
8
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
8
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
8
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
8
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
8
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
8
        const auto& vec_from = col_from->get_data();
166
8
        const auto* vec_from_data = vec_from.data();
167
8
        auto& vec_to = col_to->get_data();
168
8
        auto* vec_to_data = vec_to.data();
169
170
8
        ColumnUInt8::MutablePtr col_null_map_to;
171
8
        NullMap::value_type* null_map_data = nullptr;
172
8
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
8
        CastParameters params;
178
8
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
8
        size_t size = vec_from.size();
180
584
        for (size_t i = 0; i < size; i++) {
181
576
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
576
                                         typename ToDataType::FieldType>(
183
576
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
576
        }
191
192
8
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
8
        } else {
196
8
            block.get_by_position(result).column = std::move(col_to);
197
8
        }
198
8
        return Status::OK();
199
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
0
            null_map_data = col_null_map_to->get_data().data();
175
0
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.42k
        for (size_t i = 0; i < size; i++) {
181
1.40k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.40k
                                         typename ToDataType::FieldType>(
183
1.40k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.40k
        }
191
192
18
        if (overflow_and_nullable) {
193
0
            block.get_by_position(result).column =
194
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
18
        } else {
196
18
            block.get_by_position(result).column = std::move(col_to);
197
18
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.24k
        for (size_t i = 0; i < size; i++) {
181
1.22k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.22k
                                         typename ToDataType::FieldType>(
183
1.22k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.22k
        }
191
192
18
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
12
        } else {
196
12
            block.get_by_position(result).column = std::move(col_to);
197
12
        }
198
18
        return Status::OK();
199
18
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
18
                        const NullMap::value_type* null_map = nullptr) const override {
143
18
        using ToFieldType = typename ToDataType::FieldType;
144
145
18
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
146
18
        const auto* col_from =
147
18
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
148
18
        if (!col_from) {
149
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
150
0
                                                     type_to_string(FromDataType::PType),
151
0
                                                     named_from.column->get_name()));
152
0
        }
153
18
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
154
18
        UInt32 from_precision = from_decimal_type.get_precision();
155
18
        UInt32 from_scale = from_decimal_type.get_scale();
156
157
        // may overflow if integer part of decimal is larger than to_max_digits
158
        // in strict mode we also decide nullable on this.
159
18
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
160
18
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
161
        // only in non-strict mode and may overflow, we set nullable
162
18
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
163
164
18
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
165
18
        const auto& vec_from = col_from->get_data();
166
18
        const auto* vec_from_data = vec_from.data();
167
18
        auto& vec_to = col_to->get_data();
168
18
        auto* vec_to_data = vec_to.data();
169
170
18
        ColumnUInt8::MutablePtr col_null_map_to;
171
18
        NullMap::value_type* null_map_data = nullptr;
172
18
        if (overflow_and_nullable) {
173
6
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
174
6
            null_map_data = col_null_map_to->get_data().data();
175
6
        }
176
177
18
        CastParameters params;
178
18
        params.is_strict = (CastMode == CastModeType::StrictMode);
179
18
        size_t size = vec_from.size();
180
1.24k
        for (size_t i = 0; i < size; i++) {
181
1.22k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
182
1.22k
                                         typename ToDataType::FieldType>(
183
1.22k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
184
0
                if (set_nullable) {
185
0
                    null_map_data[i] = 1;
186
0
                } else {
187
0
                    return params.status;
188
0
                }
189
0
            }
190
1.22k
        }
191
192
18
        if (overflow_and_nullable) {
193
6
            block.get_by_position(result).column =
194
6
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
195
12
        } else {
196
12
            block.get_by_position(result).column = std::move(col_to);
197
12
        }
198
18
        return Status::OK();
199
18
    }
200
};
201
202
template <typename T>
203
constexpr static bool int_allow_cast_from_date =
204
        std::is_same_v<T, DataTypeInt32> || std::is_same_v<T, DataTypeInt64> ||
205
        std::is_same_v<T, DataTypeInt128>;
206
207
template <typename T>
208
constexpr static bool int_allow_cast_from_datetime =
209
        std::is_same_v<T, DataTypeInt64> || std::is_same_v<T, DataTypeInt128>;
210
211
// cast from date and datetime to int
212
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
213
    requires(((IsDateType<FromDataType> ||
214
               IsDateV2Type<FromDataType>)&&int_allow_cast_from_date<ToDataType>) ||
215
             ((IsDateTimeType<FromDataType> ||
216
               IsDateTimeV2Type<FromDataType>)&&int_allow_cast_from_datetime<ToDataType>))
217
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
218
public:
219
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
220
                        uint32_t result, size_t input_rows_count,
221
44
                        const NullMap::value_type* null_map = nullptr) const override {
222
44
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
44
                                                                 input_rows_count);
224
44
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
8
                        const NullMap::value_type* null_map = nullptr) const override {
222
8
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
8
                                                                 input_rows_count);
224
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
8
                        const NullMap::value_type* null_map = nullptr) const override {
222
8
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
8
                                                                 input_rows_count);
224
8
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
2
                        const NullMap::value_type* null_map = nullptr) const override {
222
2
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
2
                                                                 input_rows_count);
224
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
8
                        const NullMap::value_type* null_map = nullptr) const override {
222
8
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
8
                                                                 input_rows_count);
224
8
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
221
8
                        const NullMap::value_type* null_map = nullptr) const override {
222
8
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
223
8
                                                                 input_rows_count);
224
8
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
225
};
226
} // namespace doris