Coverage Report

Created: 2026-04-10 04:05

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
1.17k
                        const NullMap::value_type* null_map = nullptr) const override {
58
1.17k
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
1.17k
                block.get_by_position(arguments[0]).column.get());
60
1.17k
        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
1.17k
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
674
        const auto& vec_from = col_from->get_data();
68
674
        auto& vec_to = col_to->get_data();
69
674
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
674
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
674
        CastParameters params;
73
674
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
3.93k
        for (size_t i = 0; i < input_rows_count; ++i) {
75
2.11k
            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
260
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
80
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
40
                        vec_null_map_to[i] = 1;
81
40
                        continue;
82
40
                    } else {
83
40
                        return params.status;
84
40
                    }
85
80
                }
86
896
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
896
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
312
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
156
                        vec_null_map_to[i] = 1;
90
156
                        continue;
91
156
                    } else {
92
156
                        return params.status;
93
156
                    }
94
312
                }
95
960
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
960
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
904
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
452
                        vec_null_map_to[i] = 1;
99
452
                        continue;
100
452
                    } else {
101
452
                        return params.status;
102
452
                    }
103
904
                }
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
2.11k
        }
110
1.14k
        block.get_by_position(result).column =
111
1.14k
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
1.14k
        return Status::OK();
114
498
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
21
                        const NullMap::value_type* null_map = nullptr) const override {
58
21
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
21
                block.get_by_position(arguments[0]).column.get());
60
21
        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
21
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
21
        const auto& vec_from = col_from->get_data();
68
21
        auto& vec_to = col_to->get_data();
69
21
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
21
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
21
        CastParameters params;
73
21
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
59
        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
38
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
38
                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
38
        }
110
21
        block.get_by_position(result).column =
111
21
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
21
        return Status::OK();
114
21
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
60
        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
38
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
38
                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
38
        }
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
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
25
                        const NullMap::value_type* null_map = nullptr) const override {
58
25
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
25
                block.get_by_position(arguments[0]).column.get());
60
25
        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
25
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
25
        const auto& vec_from = col_from->get_data();
68
25
        auto& vec_to = col_to->get_data();
69
25
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
25
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
25
        CastParameters params;
73
25
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
67
        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
42
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
42
                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
24
                    } else {
92
24
                        return params.status;
93
24
                    }
94
24
                }
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
42
        }
110
25
        block.get_by_position(result).column =
111
25
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
25
        return Status::OK();
114
25
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
68
        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
42
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
42
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
24
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
24
                        vec_null_map_to[i] = 1;
90
24
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
24
                }
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
42
        }
110
26
        block.get_by_position(result).column =
111
26
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
26
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
160
                        const NullMap::value_type* null_map = nullptr) const override {
58
160
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
160
                block.get_by_position(arguments[0]).column.get());
60
160
        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
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
160
        const auto& vec_from = col_from->get_data();
68
160
        auto& vec_to = col_to->get_data();
69
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
160
        CastParameters params;
73
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
320
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                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
158
                    } else {
101
158
                        return params.status;
102
158
                    }
103
158
                }
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
160
        }
110
160
        block.get_by_position(result).column =
111
160
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
160
        return Status::OK();
114
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
160
                        const NullMap::value_type* null_map = nullptr) const override {
58
160
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
160
                block.get_by_position(arguments[0]).column.get());
60
160
        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
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
160
        const auto& vec_from = col_from->get_data();
68
160
        auto& vec_to = col_to->get_data();
69
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
160
        CastParameters params;
73
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
478
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
158
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
158
                        vec_null_map_to[i] = 1;
99
158
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
158
                }
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
160
        }
110
318
        block.get_by_position(result).column =
111
318
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
318
        return Status::OK();
114
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
19
                        const NullMap::value_type* null_map = nullptr) const override {
58
19
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
19
                block.get_by_position(arguments[0]).column.get());
60
19
        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
19
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
19
        const auto& vec_from = col_from->get_data();
68
19
        auto& vec_to = col_to->get_data();
69
19
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
19
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
19
        CastParameters params;
73
19
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
59
        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
40
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
40
                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
18
                    } else {
92
18
                        return params.status;
93
18
                    }
94
18
                }
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
40
        }
110
19
        block.get_by_position(result).column =
111
19
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
19
        return Status::OK();
114
19
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
60
        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
40
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
40
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
18
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
18
                        vec_null_map_to[i] = 1;
90
18
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
18
                }
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
40
        }
110
20
        block.get_by_position(result).column =
111
20
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
20
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
23
                        const NullMap::value_type* null_map = nullptr) const override {
58
23
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
23
                block.get_by_position(arguments[0]).column.get());
60
23
        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
23
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
23
        const auto& vec_from = col_from->get_data();
68
23
        auto& vec_to = col_to->get_data();
69
23
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
23
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
23
        CastParameters params;
73
23
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
67
        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
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
44
                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
22
                    } else {
92
22
                        return params.status;
93
22
                    }
94
22
                }
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
44
        }
110
23
        block.get_by_position(result).column =
111
23
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
23
        return Status::OK();
114
23
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
68
        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
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
22
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
22
                        vec_null_map_to[i] = 1;
90
22
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
22
                }
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
44
        }
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
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
160
                        const NullMap::value_type* null_map = nullptr) const override {
58
160
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
160
                block.get_by_position(arguments[0]).column.get());
60
160
        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
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
160
        const auto& vec_from = col_from->get_data();
68
160
        auto& vec_to = col_to->get_data();
69
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
160
        CastParameters params;
73
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
320
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                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
158
                    } else {
101
158
                        return params.status;
102
158
                    }
103
158
                }
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
160
        }
110
160
        block.get_by_position(result).column =
111
160
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
160
        return Status::OK();
114
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
160
                        const NullMap::value_type* null_map = nullptr) const override {
58
160
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
160
                block.get_by_position(arguments[0]).column.get());
60
160
        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
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
160
        const auto& vec_from = col_from->get_data();
68
160
        auto& vec_to = col_to->get_data();
69
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
160
        CastParameters params;
73
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
478
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
158
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
158
                        vec_null_map_to[i] = 1;
99
158
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
158
                }
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
160
        }
110
318
        block.get_by_position(result).column =
111
318
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
318
        return Status::OK();
114
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
15
                        const NullMap::value_type* null_map = nullptr) const override {
58
15
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
15
                block.get_by_position(arguments[0]).column.get());
60
15
        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
15
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
15
        const auto& vec_from = col_from->get_data();
68
15
        auto& vec_to = col_to->get_data();
69
15
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
15
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
15
        CastParameters params;
73
15
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
59
        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
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
44
                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
14
                    } else {
92
14
                        return params.status;
93
14
                    }
94
14
                }
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
44
        }
110
15
        block.get_by_position(result).column =
111
15
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
15
        return Status::OK();
114
15
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
60
        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
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
14
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
14
                        vec_null_map_to[i] = 1;
90
14
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
14
                }
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
44
        }
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
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
19
                        const NullMap::value_type* null_map = nullptr) const override {
58
19
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
19
                block.get_by_position(arguments[0]).column.get());
60
19
        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
19
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
19
        const auto& vec_from = col_from->get_data();
68
19
        auto& vec_to = col_to->get_data();
69
19
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
19
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
19
        CastParameters params;
73
19
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
67
        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
48
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
48
                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
18
                    } else {
92
18
                        return params.status;
93
18
                    }
94
18
                }
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
48
        }
110
19
        block.get_by_position(result).column =
111
19
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
19
        return Status::OK();
114
19
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
68
        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
48
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
48
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
18
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
18
                        vec_null_map_to[i] = 1;
90
18
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
18
                }
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
48
        }
110
20
        block.get_by_position(result).column =
111
20
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
20
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
138
                        const NullMap::value_type* null_map = nullptr) const override {
58
138
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
138
                block.get_by_position(arguments[0]).column.get());
60
138
        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
138
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
138
        const auto& vec_from = col_from->get_data();
68
138
        auto& vec_to = col_to->get_data();
69
138
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
138
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
138
        CastParameters params;
73
138
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
298
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                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
136
                    } else {
101
136
                        return params.status;
102
136
                    }
103
136
                }
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
160
        }
110
138
        block.get_by_position(result).column =
111
138
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
138
        return Status::OK();
114
138
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
138
                        const NullMap::value_type* null_map = nullptr) const override {
58
138
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
138
                block.get_by_position(arguments[0]).column.get());
60
138
        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
138
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
138
        const auto& vec_from = col_from->get_data();
68
138
        auto& vec_to = col_to->get_data();
69
138
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
138
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
138
        CastParameters params;
73
138
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
434
        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
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
96
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
97
136
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
98
136
                        vec_null_map_to[i] = 1;
99
136
                        continue;
100
                    } else {
101
                        return params.status;
102
                    }
103
136
                }
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
160
        }
110
274
        block.get_by_position(result).column =
111
274
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
274
        return Status::OK();
114
138
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
5
                        const NullMap::value_type* null_map = nullptr) const override {
58
5
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
5
                block.get_by_position(arguments[0]).column.get());
60
5
        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
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
5
        const auto& vec_from = col_from->get_data();
68
5
        auto& vec_to = col_to->get_data();
69
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
5
        CastParameters params;
73
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
18
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                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
4
                    } else {
83
4
                        return params.status;
84
4
                    }
85
4
                }
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
13
        }
110
5
        block.get_by_position(result).column =
111
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
5
        return Status::OK();
114
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
19
        for (size_t i = 0; i < input_rows_count; ++i) {
75
13
            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
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
79
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
80
4
                        vec_null_map_to[i] = 1;
81
4
                        continue;
82
                    } else {
83
                        return params.status;
84
                    }
85
4
                }
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
13
        }
110
6
        block.get_by_position(result).column =
111
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
6
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
11
                        const NullMap::value_type* null_map = nullptr) const override {
58
11
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
11
                block.get_by_position(arguments[0]).column.get());
60
11
        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
11
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
11
        const auto& vec_from = col_from->get_data();
68
11
        auto& vec_to = col_to->get_data();
69
11
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
11
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
11
        CastParameters params;
73
11
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
57
        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
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
46
                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
10
                    } else {
92
10
                        return params.status;
93
10
                    }
94
10
                }
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
46
        }
110
11
        block.get_by_position(result).column =
111
11
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
11
        return Status::OK();
114
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
58
        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
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
10
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
10
                        vec_null_map_to[i] = 1;
90
10
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
10
                }
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
46
        }
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
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
15
                        const NullMap::value_type* null_map = nullptr) const override {
58
15
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
15
                block.get_by_position(arguments[0]).column.get());
60
15
        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
15
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
15
        const auto& vec_from = col_from->get_data();
68
15
        auto& vec_to = col_to->get_data();
69
15
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
15
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
15
        CastParameters params;
73
15
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
65
        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
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
50
                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
14
                    } else {
92
14
                        return params.status;
93
14
                    }
94
14
                }
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
50
        }
110
15
        block.get_by_position(result).column =
111
15
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
15
        return Status::OK();
114
15
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
66
        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
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
50
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
14
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
14
                        vec_null_map_to[i] = 1;
90
14
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
14
                }
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
50
        }
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
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
7
                        const NullMap::value_type* null_map = nullptr) const override {
58
7
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
7
                block.get_by_position(arguments[0]).column.get());
60
7
        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
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
7
        const auto& vec_from = col_from->get_data();
68
7
        auto& vec_to = col_to->get_data();
69
7
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
7
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
7
        CastParameters params;
73
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
53
        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
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
46
                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
6
                    } else {
92
6
                        return params.status;
93
6
                    }
94
6
                }
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
46
        }
110
7
        block.get_by_position(result).column =
111
7
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
7
        return Status::OK();
114
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
54
        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
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
6
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
6
                        vec_null_map_to[i] = 1;
90
6
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
6
                }
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
46
        }
110
8
        block.get_by_position(result).column =
111
8
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
8
        return Status::OK();
114
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
11
                        const NullMap::value_type* null_map = nullptr) const override {
58
11
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
11
                block.get_by_position(arguments[0]).column.get());
60
11
        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
11
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
11
        const auto& vec_from = col_from->get_data();
68
11
        auto& vec_to = col_to->get_data();
69
11
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
11
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
11
        CastParameters params;
73
11
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
61
        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
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
50
                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
10
                    } else {
92
10
                        return params.status;
93
10
                    }
94
10
                }
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
50
        }
110
11
        block.get_by_position(result).column =
111
11
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
112
113
11
        return Status::OK();
114
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
57
2
                        const NullMap::value_type* null_map = nullptr) const override {
58
2
        const auto* col_from = check_and_get_column<typename FromDataType::ColumnType>(
59
2
                block.get_by_position(arguments[0]).column.get());
60
2
        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
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
67
2
        const auto& vec_from = col_from->get_data();
68
2
        auto& vec_to = col_to->get_data();
69
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
70
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
71
72
2
        CastParameters params;
73
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
74
62
        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
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
87
50
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
88
10
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
89
10
                        vec_null_map_to[i] = 1;
90
10
                        continue;
91
                    } else {
92
                        return params.status;
93
                    }
94
10
                }
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
50
        }
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
2
    }
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
319
                        const NullMap::value_type* null_map = nullptr) const override {
130
319
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
319
                                                                 input_rows_count);
132
319
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
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
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
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
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_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_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_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_13PrimitiveTypeE2EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
87
                        const NullMap::value_type* null_map = nullptr) const override {
130
87
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
87
                                                                 input_rows_count);
132
87
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_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
    }
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
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_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_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_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
98
                        const NullMap::value_type* null_map = nullptr) const override {
130
98
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
98
                                                                 input_rows_count);
132
98
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
1
                        const NullMap::value_type* null_map = nullptr) const override {
130
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
1
                                                                 input_rows_count);
132
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
129
95
                        const NullMap::value_type* null_map = nullptr) const override {
130
95
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
131
95
                                                                 input_rows_count);
132
95
    }
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
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_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_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
    }
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
380
                        const NullMap::value_type* null_map = nullptr) const override {
143
380
        using ToFieldType = typename ToDataType::FieldType;
144
380
        using FromFieldType = typename FromDataType::FieldType;
145
146
380
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
380
        const auto* col_from =
148
380
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
380
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
380
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
380
        UInt32 from_precision = from_decimal_type.get_precision();
156
380
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
380
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
380
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
380
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
380
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
380
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
380
        const auto& vec_from = col_from->get_data();
169
380
        const auto* vec_from_data = vec_from.data();
170
380
        auto& vec_to = col_to->get_data();
171
380
        auto* vec_to_data = vec_to.data();
172
173
380
        ColumnUInt8::MutablePtr col_null_map_to;
174
380
        NullMap::value_type* null_map_data = nullptr;
175
380
        if (overflow_and_nullable) {
176
146
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
146
            null_map_data = col_null_map_to->get_data().data();
178
146
        }
179
180
380
        CastParameters params;
181
380
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
380
        size_t size = vec_from.size();
183
380
        typename FromFieldType::NativeType scale_multiplier =
184
380
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
22.4k
        for (size_t i = 0; i < size; i++) {
186
22.1k
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
22.1k
                                          typename ToDataType::FieldType>(
188
22.1k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
22.1k
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
22.1k
        }
197
198
380
        if (overflow_and_nullable) {
199
146
            block.get_by_position(result).column =
200
146
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
234
        } else {
202
234
            block.get_by_position(result).column = std::move(col_to);
203
234
        }
204
380
        return Status::OK();
205
380
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
302
        for (size_t i = 0; i < size; i++) {
186
295
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
295
                                          typename ToDataType::FieldType>(
188
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
295
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
295
        }
197
198
7
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
302
        for (size_t i = 0; i < size; i++) {
186
295
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
295
                                          typename ToDataType::FieldType>(
188
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
295
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
295
        }
197
198
7
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
302
        for (size_t i = 0; i < size; i++) {
186
295
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
295
                                          typename ToDataType::FieldType>(
188
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
295
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
295
        }
197
198
7
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
302
        for (size_t i = 0; i < size; i++) {
186
295
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
295
                                          typename ToDataType::FieldType>(
188
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
295
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
295
        }
197
198
7
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
623
        for (size_t i = 0; i < size; i++) {
186
614
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
614
                                          typename ToDataType::FieldType>(
188
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
614
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
614
        }
197
198
9
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
6
        } else {
202
6
            block.get_by_position(result).column = std::move(col_to);
203
6
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
623
        for (size_t i = 0; i < size; i++) {
186
614
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
614
                                          typename ToDataType::FieldType>(
188
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
614
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
614
        }
197
198
9
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
6
        } else {
202
6
            block.get_by_position(result).column = std::move(col_to);
203
6
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
148
        for (size_t i = 0; i < size; i++) {
186
144
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
144
                                          typename ToDataType::FieldType>(
188
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
144
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
144
        }
197
198
4
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
0
            block.get_by_position(result).column = std::move(col_to);
203
0
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
292
        for (size_t i = 0; i < size; i++) {
186
288
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
288
                                          typename ToDataType::FieldType>(
188
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
288
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
288
        }
197
198
4
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
292
        for (size_t i = 0; i < size; i++) {
186
288
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
288
                                          typename ToDataType::FieldType>(
188
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
288
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
288
        }
197
198
4
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
551
        for (size_t i = 0; i < size; i++) {
186
542
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
542
                                          typename ToDataType::FieldType>(
188
542
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
542
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
542
        }
197
198
9
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
5
            block.get_by_position(result).column = std::move(col_to);
203
5
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
4
            null_map_data = col_null_map_to->get_data().data();
178
4
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
551
        for (size_t i = 0; i < size; i++) {
186
542
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
542
                                          typename ToDataType::FieldType>(
188
542
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
542
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
542
        }
197
198
9
        if (overflow_and_nullable) {
199
4
            block.get_by_position(result).column =
200
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
5
            block.get_by_position(result).column = std::move(col_to);
203
5
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
5
            null_map_data = col_null_map_to->get_data().data();
178
5
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
479
        for (size_t i = 0; i < size; i++) {
186
470
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
470
                                          typename ToDataType::FieldType>(
188
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
470
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
470
        }
197
198
9
        if (overflow_and_nullable) {
199
5
            block.get_by_position(result).column =
200
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
5
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
7
                        const NullMap::value_type* null_map = nullptr) const override {
143
7
        using ToFieldType = typename ToDataType::FieldType;
144
7
        using FromFieldType = typename FromDataType::FieldType;
145
146
7
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
7
        const auto* col_from =
148
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
7
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
7
        UInt32 from_precision = from_decimal_type.get_precision();
156
7
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
7
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
7
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
7
        const auto& vec_from = col_from->get_data();
169
7
        const auto* vec_from_data = vec_from.data();
170
7
        auto& vec_to = col_to->get_data();
171
7
        auto* vec_to_data = vec_to.data();
172
173
7
        ColumnUInt8::MutablePtr col_null_map_to;
174
7
        NullMap::value_type* null_map_data = nullptr;
175
7
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
7
        CastParameters params;
181
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
7
        size_t size = vec_from.size();
183
7
        typename FromFieldType::NativeType scale_multiplier =
184
7
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
455
        for (size_t i = 0; i < size; i++) {
186
448
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
448
                                          typename ToDataType::FieldType>(
188
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
448
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
448
        }
197
198
7
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
7
        } else {
202
7
            block.get_by_position(result).column = std::move(col_to);
203
7
        }
204
7
        return Status::OK();
205
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
292
        for (size_t i = 0; i < size; i++) {
186
288
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
288
                                          typename ToDataType::FieldType>(
188
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
288
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
288
        }
197
198
4
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
4
                        const NullMap::value_type* null_map = nullptr) const override {
143
4
        using ToFieldType = typename ToDataType::FieldType;
144
4
        using FromFieldType = typename FromDataType::FieldType;
145
146
4
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
4
        const auto* col_from =
148
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
4
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
4
        UInt32 from_precision = from_decimal_type.get_precision();
156
4
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
4
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
4
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
4
        const auto& vec_from = col_from->get_data();
169
4
        const auto* vec_from_data = vec_from.data();
170
4
        auto& vec_to = col_to->get_data();
171
4
        auto* vec_to_data = vec_to.data();
172
173
4
        ColumnUInt8::MutablePtr col_null_map_to;
174
4
        NullMap::value_type* null_map_data = nullptr;
175
4
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
4
        CastParameters params;
181
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
4
        size_t size = vec_from.size();
183
4
        typename FromFieldType::NativeType scale_multiplier =
184
4
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
292
        for (size_t i = 0; i < size; i++) {
186
288
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
288
                                          typename ToDataType::FieldType>(
188
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
288
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
288
        }
197
198
4
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
4
        } else {
202
4
            block.get_by_position(result).column = std::move(col_to);
203
4
        }
204
4
        return Status::OK();
205
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
0
            null_map_data = col_null_map_to->get_data().data();
178
0
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
713
        for (size_t i = 0; i < size; i++) {
186
704
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
704
                                          typename ToDataType::FieldType>(
188
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
704
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
704
        }
197
198
9
        if (overflow_and_nullable) {
199
0
            block.get_by_position(result).column =
200
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
9
        } else {
202
9
            block.get_by_position(result).column = std::move(col_to);
203
9
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
623
        for (size_t i = 0; i < size; i++) {
186
614
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
614
                                          typename ToDataType::FieldType>(
188
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
614
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
614
        }
197
198
9
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
6
        } else {
202
6
            block.get_by_position(result).column = std::move(col_to);
203
6
        }
204
9
        return Status::OK();
205
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
142
9
                        const NullMap::value_type* null_map = nullptr) const override {
143
9
        using ToFieldType = typename ToDataType::FieldType;
144
9
        using FromFieldType = typename FromDataType::FieldType;
145
146
9
        const ColumnWithTypeAndName& named_from = block.get_by_position(arguments[0]);
147
9
        const auto* col_from =
148
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
149
9
        if (!col_from) {
150
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
151
0
                                                     type_to_string(FromDataType::PType),
152
0
                                                     named_from.column->get_name()));
153
0
        }
154
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
155
9
        UInt32 from_precision = from_decimal_type.get_precision();
156
9
        UInt32 from_scale = from_decimal_type.get_scale();
157
158
9
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
159
9
        bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
160
161
        // may overflow if integer part of decimal is larger than to_max_digits
162
        // in strict mode we also decide nullable on this.
163
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
164
        // only in non-strict mode and may overflow, we set nullable
165
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
166
167
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
168
9
        const auto& vec_from = col_from->get_data();
169
9
        const auto* vec_from_data = vec_from.data();
170
9
        auto& vec_to = col_to->get_data();
171
9
        auto* vec_to_data = vec_to.data();
172
173
9
        ColumnUInt8::MutablePtr col_null_map_to;
174
9
        NullMap::value_type* null_map_data = nullptr;
175
9
        if (overflow_and_nullable) {
176
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
177
3
            null_map_data = col_null_map_to->get_data().data();
178
3
        }
179
180
9
        CastParameters params;
181
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
182
9
        size_t size = vec_from.size();
183
9
        typename FromFieldType::NativeType scale_multiplier =
184
9
                DataTypeDecimal<FromDataType::PType>::get_scale_multiplier(from_scale);
185
623
        for (size_t i = 0; i < size; i++) {
186
614
            if (!CastToInt::_from_decimal<typename FromDataType::FieldType,
187
614
                                          typename ToDataType::FieldType>(
188
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i],
189
614
                        scale_multiplier, narrow_integral, params)) {
190
0
                if (set_nullable) {
191
0
                    null_map_data[i] = 1;
192
0
                } else {
193
0
                    return params.status;
194
0
                }
195
0
            }
196
614
        }
197
198
9
        if (overflow_and_nullable) {
199
3
            block.get_by_position(result).column =
200
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
201
6
        } else {
202
6
            block.get_by_position(result).column = std::move(col_to);
203
6
        }
204
9
        return Status::OK();
205
9
    }
206
};
207
208
template <typename T>
209
constexpr static bool int_allow_cast_from_date =
210
        std::is_same_v<T, DataTypeInt32> || std::is_same_v<T, DataTypeInt64> ||
211
        std::is_same_v<T, DataTypeInt128>;
212
213
template <typename T>
214
constexpr static bool int_allow_cast_from_datetime =
215
        std::is_same_v<T, DataTypeInt64> || std::is_same_v<T, DataTypeInt128>;
216
217
// cast from date and datetime to int
218
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
219
    requires(((IsDateType<FromDataType> ||
220
               IsDateV2Type<FromDataType>)&&int_allow_cast_from_date<ToDataType>) ||
221
             ((IsDateTimeType<FromDataType> ||
222
               IsDateTimeV2Type<FromDataType>)&&int_allow_cast_from_datetime<ToDataType>))
223
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
224
public:
225
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
226
                        uint32_t result, size_t input_rows_count,
227
22
                        const NullMap::value_type* null_map = nullptr) const override {
228
22
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
22
                                                                 input_rows_count);
230
22
    }
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
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
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
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
4
                        const NullMap::value_type* null_map = nullptr) const override {
228
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
4
                                                                 input_rows_count);
230
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
4
                        const NullMap::value_type* null_map = nullptr) const override {
228
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
4
                                                                 input_rows_count);
230
4
    }
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
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
1
                        const NullMap::value_type* null_map = nullptr) const override {
228
1
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
1
                                                                 input_rows_count);
230
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
4
                        const NullMap::value_type* null_map = nullptr) const override {
228
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
4
                                                                 input_rows_count);
230
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
227
4
                        const NullMap::value_type* null_map = nullptr) const override {
228
4
        return static_cast_no_overflow<FromDataType, ToDataType>(context, block, arguments, result,
229
4
                                                                 input_rows_count);
230
4
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
231
};
232
} // namespace doris