Coverage Report

Created: 2026-10-28 22:39

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(RuntimeState* /*state*/, const ColumnWithTypeAndName& source_column,
56
                        ColumnWithTypeAndName& target_column, size_t input_rows_count,
57
1.24k
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
1.24k
        const auto* col_from =
59
1.24k
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
1.24k
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
1.24k
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
704
        const auto& vec_from = col_from->get_data();
67
704
        auto& vec_to = col_to->get_data();
68
704
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
704
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
704
        CastParameters params;
72
704
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
16.4k
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
14.5k
            if (parent_null_map && parent_null_map[i]) {
77
22
                continue;
78
22
            }
79
14.5k
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
12.6k
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
97
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
46
                        vec_null_map_to[i] = 1;
85
46
                        continue;
86
51
                    } else {
87
51
                        return params.status;
88
51
                    }
89
97
                }
90
12.6k
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
899
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
312
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
156
                        vec_null_map_to[i] = 1;
94
156
                        continue;
95
156
                    } else {
96
156
                        return params.status;
97
156
                    }
98
312
                }
99
960
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
960
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
904
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
452
                        vec_null_map_to[i] = 1;
103
452
                        continue;
104
452
                    } else {
105
452
                        return params.status;
106
452
                    }
107
904
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
14.5k
        }
114
1.19k
        target_column.column =
115
1.19k
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
1.19k
        return Status::OK();
118
543
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
34
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
34
        const auto* col_from =
59
34
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
34
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
34
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
34
        const auto& vec_from = col_from->get_data();
67
34
        auto& vec_to = col_to->get_data();
68
34
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
34
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
34
        CastParameters params;
72
34
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
97
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
63
            if (parent_null_map && parent_null_map[i]) {
77
15
                continue;
78
15
            }
79
48
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
48
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
15
                    } else {
87
15
                        return params.status;
88
15
                    }
89
15
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
48
        }
114
34
        target_column.column =
115
34
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
34
        return Status::OK();
118
34
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
7
        const auto* col_from =
59
7
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
7
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
7
        const auto& vec_from = col_from->get_data();
67
7
        auto& vec_to = col_to->get_data();
68
7
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
7
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
7
        CastParameters params;
72
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
45
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
29
            if (parent_null_map && parent_null_map[i]) {
77
6
                continue;
78
6
            }
79
23
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
23
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
9
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
9
                        vec_null_map_to[i] = 1;
85
9
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
9
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
23
        }
114
16
        target_column.column =
115
16
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
16
        return Status::OK();
118
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
21
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
21
        const auto* col_from =
59
21
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
21
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
21
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
21
        const auto& vec_from = col_from->get_data();
67
21
        auto& vec_to = col_to->get_data();
68
21
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
21
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
21
        CastParameters params;
72
21
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
59
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
38
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
38
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
38
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
20
                    } else {
96
20
                        return params.status;
97
20
                    }
98
20
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
38
        }
114
21
        target_column.column =
115
21
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
21
        return Status::OK();
118
21
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
60
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
38
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
38
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
38
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
20
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
20
                        vec_null_map_to[i] = 1;
94
20
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
20
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
38
        }
114
22
        target_column.column =
115
22
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
22
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
26
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
26
        const auto* col_from =
59
26
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
26
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
26
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
26
        const auto& vec_from = col_from->get_data();
67
26
        auto& vec_to = col_to->get_data();
68
26
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
26
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
26
        CastParameters params;
72
26
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
70
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
44
            if (parent_null_map && parent_null_map[i]) {
77
1
                continue;
78
1
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
43
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
43
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
24
                    } else {
96
24
                        return params.status;
97
24
                    }
98
24
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
43
        }
114
26
        target_column.column =
115
26
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
26
        return Status::OK();
118
26
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
68
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
42
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
42
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
42
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
24
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
24
                        vec_null_map_to[i] = 1;
94
24
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
24
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
42
        }
114
26
        target_column.column =
115
26
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
26
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
160
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
160
        const auto* col_from =
59
160
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
160
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
160
        const auto& vec_from = col_from->get_data();
67
160
        auto& vec_to = col_to->get_data();
68
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
160
        CastParameters params;
72
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
320
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
158
                    } else {
105
158
                        return params.status;
106
158
                    }
107
158
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
160
        target_column.column =
115
160
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
160
        return Status::OK();
118
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
160
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
160
        const auto* col_from =
59
160
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
160
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
160
        const auto& vec_from = col_from->get_data();
67
160
        auto& vec_to = col_to->get_data();
68
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
160
        CastParameters params;
72
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
478
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
158
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
158
                        vec_null_map_to[i] = 1;
103
158
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
158
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
318
        target_column.column =
115
318
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
318
        return Status::OK();
118
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
19
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
19
        const auto* col_from =
59
19
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
19
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
19
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
19
        const auto& vec_from = col_from->get_data();
67
19
        auto& vec_to = col_to->get_data();
68
19
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
19
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
19
        CastParameters params;
72
19
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
59
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
40
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
40
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
40
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
18
                    } else {
96
18
                        return params.status;
97
18
                    }
98
18
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
40
        }
114
19
        target_column.column =
115
19
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
19
        return Status::OK();
118
19
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
60
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
40
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
40
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
40
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
18
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
18
                        vec_null_map_to[i] = 1;
94
18
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
18
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
40
        }
114
20
        target_column.column =
115
20
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
20
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
23
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
23
        const auto* col_from =
59
23
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
23
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
23
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
23
        const auto& vec_from = col_from->get_data();
67
23
        auto& vec_to = col_to->get_data();
68
23
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
23
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
23
        CastParameters params;
72
23
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
67
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
44
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
22
                    } else {
96
22
                        return params.status;
97
22
                    }
98
22
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
44
        }
114
23
        target_column.column =
115
23
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
23
        return Status::OK();
118
23
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
68
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
44
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
22
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
22
                        vec_null_map_to[i] = 1;
94
22
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
22
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
44
        }
114
24
        target_column.column =
115
24
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
24
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
160
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
160
        const auto* col_from =
59
160
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
160
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
160
        const auto& vec_from = col_from->get_data();
67
160
        auto& vec_to = col_to->get_data();
68
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
160
        CastParameters params;
72
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
320
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
158
                    } else {
105
158
                        return params.status;
106
158
                    }
107
158
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
160
        target_column.column =
115
160
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
160
        return Status::OK();
118
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
160
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
160
        const auto* col_from =
59
160
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
160
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
160
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
160
        const auto& vec_from = col_from->get_data();
67
160
        auto& vec_to = col_to->get_data();
68
160
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
160
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
160
        CastParameters params;
72
160
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
478
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
158
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
158
                        vec_null_map_to[i] = 1;
103
158
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
158
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
318
        target_column.column =
115
318
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
318
        return Status::OK();
118
160
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
41
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
41
        const auto* col_from =
59
41
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
41
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
41
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
41
        const auto& vec_from = col_from->get_data();
67
41
        auto& vec_to = col_to->get_data();
68
41
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
41
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
41
        CastParameters params;
72
41
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
12.4k
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
12.3k
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
12.3k
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
12.3k
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
5
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
5
                        vec_null_map_to[i] = 1;
85
5
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
5
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
12.3k
        }
114
46
        target_column.column =
115
46
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
46
        return Status::OK();
118
41
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
15
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
15
        const auto* col_from =
59
15
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
15
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
15
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
15
        const auto& vec_from = col_from->get_data();
67
15
        auto& vec_to = col_to->get_data();
68
15
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
15
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
15
        CastParameters params;
72
15
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
59
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
44
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
14
                    } else {
96
14
                        return params.status;
97
14
                    }
98
14
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
44
        }
114
15
        target_column.column =
115
15
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
15
        return Status::OK();
118
15
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
60
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
44
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
44
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
44
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
14
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
14
                        vec_null_map_to[i] = 1;
94
14
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
14
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
44
        }
114
16
        target_column.column =
115
16
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
16
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
19
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
19
        const auto* col_from =
59
19
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
19
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
19
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
19
        const auto& vec_from = col_from->get_data();
67
19
        auto& vec_to = col_to->get_data();
68
19
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
19
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
19
        CastParameters params;
72
19
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
67
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
48
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
48
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
48
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
18
                    } else {
96
18
                        return params.status;
97
18
                    }
98
18
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
48
        }
114
19
        target_column.column =
115
19
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
19
        return Status::OK();
118
19
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
68
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
48
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
48
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
48
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
18
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
18
                        vec_null_map_to[i] = 1;
94
18
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
18
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
48
        }
114
20
        target_column.column =
115
20
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
20
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
138
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
138
        const auto* col_from =
59
138
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
138
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
138
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
138
        const auto& vec_from = col_from->get_data();
67
138
        auto& vec_to = col_to->get_data();
68
138
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
138
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
138
        CastParameters params;
72
138
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
298
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
136
                    } else {
105
136
                        return params.status;
106
136
                    }
107
136
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
138
        target_column.column =
115
138
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
138
        return Status::OK();
118
138
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
138
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
138
        const auto* col_from =
59
138
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
138
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
138
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
138
        const auto& vec_from = col_from->get_data();
67
138
        auto& vec_to = col_to->get_data();
68
138
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
138
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
138
        CastParameters params;
72
138
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
434
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
160
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
160
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
160
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
136
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
136
                        vec_null_map_to[i] = 1;
103
136
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
136
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
160
        }
114
274
        target_column.column =
115
274
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
274
        return Status::OK();
118
138
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
5
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
5
        const auto* col_from =
59
5
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
5
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
5
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
5
        const auto& vec_from = col_from->get_data();
67
5
        auto& vec_to = col_to->get_data();
68
5
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
5
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
5
        CastParameters params;
72
5
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
18
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
4
                    } else {
87
4
                        return params.status;
88
4
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
5
        target_column.column =
115
5
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
5
        return Status::OK();
118
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
19
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
13
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
13
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
13
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
4
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
4
                        vec_null_map_to[i] = 1;
85
4
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
4
                }
90
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
13
        }
114
6
        target_column.column =
115
6
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
6
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
11
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
11
        const auto* col_from =
59
11
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
11
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
11
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
11
        const auto& vec_from = col_from->get_data();
67
11
        auto& vec_to = col_to->get_data();
68
11
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
11
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
11
        CastParameters params;
72
11
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
57
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
46
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
10
                    } else {
96
10
                        return params.status;
97
10
                    }
98
10
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
46
        }
114
11
        target_column.column =
115
11
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
11
        return Status::OK();
118
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
58
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
46
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
10
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
10
                        vec_null_map_to[i] = 1;
94
10
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
10
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
46
        }
114
12
        target_column.column =
115
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
12
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
15
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
15
        const auto* col_from =
59
15
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
15
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
15
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
15
        const auto& vec_from = col_from->get_data();
67
15
        auto& vec_to = col_to->get_data();
68
15
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
15
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
15
        CastParameters params;
72
15
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
65
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
50
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
50
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
14
                    } else {
96
14
                        return params.status;
97
14
                    }
98
14
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
50
        }
114
15
        target_column.column =
115
15
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
15
        return Status::OK();
118
15
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
3
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
3
        const auto* col_from =
59
3
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
3
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
3
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
3
        const auto& vec_from = col_from->get_data();
67
3
        auto& vec_to = col_to->get_data();
68
3
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
3
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
3
        CastParameters params;
72
3
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
69
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
52
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
52
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
52
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
14
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
14
                        vec_null_map_to[i] = 1;
94
14
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
14
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
52
        }
114
17
        target_column.column =
115
17
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
17
        return Status::OK();
118
3
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
7
        const auto* col_from =
59
7
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
7
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
7
        const auto& vec_from = col_from->get_data();
67
7
        auto& vec_to = col_to->get_data();
68
7
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
7
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
7
        CastParameters params;
72
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
53
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
46
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
6
                    } else {
96
6
                        return params.status;
97
6
                    }
98
6
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
46
        }
114
7
        target_column.column =
115
7
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
7
        return Status::OK();
118
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE8EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
54
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
46
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
46
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
46
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
6
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
6
                        vec_null_map_to[i] = 1;
94
6
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
6
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
46
        }
114
8
        target_column.column =
115
8
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
8
        return Status::OK();
118
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
11
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
11
        const auto* col_from =
59
11
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
11
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
11
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
11
        const auto& vec_from = col_from->get_data();
67
11
        auto& vec_to = col_to->get_data();
68
11
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
11
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
11
        CastParameters params;
72
11
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
61
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
50
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
50
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
                        vec_null_map_to[i] = 1;
94
                        continue;
95
10
                    } else {
96
10
                        return params.status;
97
10
                    }
98
10
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
50
        }
114
11
        target_column.column =
115
11
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
11
        return Status::OK();
118
11
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE9EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
57
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
58
2
        const auto* col_from =
59
2
                check_and_get_column<typename FromDataType::ColumnType>(source_column.column.get());
60
2
        if (!col_from) {
61
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
62
0
                                                     type_to_string(FromDataType::PType),
63
0
                                                     source_column.column->get_name()));
64
0
        }
65
2
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
66
2
        const auto& vec_from = col_from->get_data();
67
2
        auto& vec_to = col_to->get_data();
68
2
        ColumnBool::MutablePtr col_null_map_to = ColumnBool::create(input_rows_count, 0);
69
2
        NullMap::value_type* vec_null_map_to = col_null_map_to->get_data().data();
70
71
2
        CastParameters params;
72
2
        params.is_strict = (CastMode == CastModeType::StrictMode);
73
62
        for (size_t i = 0; i < input_rows_count; ++i) {
74
            // The source value of a row marked as null by the input null map is a hidden
75
            // payload and has no SQL semantics, so it must not be checked.
76
50
            if (parent_null_map && parent_null_map[i]) {
77
0
                continue;
78
0
            }
79
            if constexpr (IsDataTypeInt<FromDataType>) {
80
                // although always nullable output, but only set null when overflow in non-strict mode.
81
                // in strict mode, just raise error on overflow.
82
                if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
83
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
84
                        vec_null_map_to[i] = 1;
85
                        continue;
86
                    } else {
87
                        return params.status;
88
                    }
89
                }
90
50
            } else if constexpr (IsDataTypeFloat<FromDataType>) {
91
50
                if (!CastToInt::from_float(vec_from[i], vec_to[i], params)) {
92
10
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
93
10
                        vec_null_map_to[i] = 1;
94
10
                        continue;
95
                    } else {
96
                        return params.status;
97
                    }
98
10
                }
99
            } else if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) {
100
                if (!CastToInt::from_time(vec_from[i], vec_to[i], params)) {
101
                    if constexpr (CastMode == CastModeType::NonStrictMode) {
102
                        vec_null_map_to[i] = 1;
103
                        continue;
104
                    } else {
105
                        return params.status;
106
                    }
107
                }
108
            } else {
109
                return Status::InternalError(fmt::format("Unsupported cast from {} to {}",
110
                                                         type_to_string(FromDataType::PType),
111
                                                         type_to_string(ToDataType::PType)));
112
            }
113
50
        }
114
12
        target_column.column =
115
12
                ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
116
117
12
        return Status::OK();
118
2
    }
119
};
120
121
/// cast to int, will not overflow and no nullable output:
122
/// 1. from bool;
123
/// 2. from narrow int to wider int
124
/// 3. from time to bigint and largeint
125
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
126
    requires(IsDataTypeInt<ToDataType> &&
127
             (IsDataTypeNumber<FromDataType> || std::is_same_v<FromDataType, DataTypeTimeV2>) &&
128
             !CastToIntMayOverflow<FromDataType, ToDataType>)
129
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
130
public:
131
    Status execute_impl(RuntimeState* state, const ColumnWithTypeAndName& source_column,
132
                        ColumnWithTypeAndName& target_column, size_t input_rows_count,
133
63
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
63
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
63
                state, source_column, target_column, input_rows_count, parent_null_map);
136
63
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
4
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
4
                state, source_column, target_column, input_rows_count, parent_null_map);
136
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
19
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
19
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
19
                state, source_column, target_column, input_rows_count, parent_null_map);
136
19
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE2EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE3EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE4EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEENS2_ILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
1
                state, source_column, target_column, input_rows_count, parent_null_map);
136
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEES4_E12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS8_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
133
2
                        const NullMap::value_type* parent_null_map = nullptr) const override {
134
2
        return static_cast_no_overflow<FromDataType, ToDataType>(
135
2
                state, source_column, target_column, input_rows_count, parent_null_map);
136
2
    }
137
};
138
139
// cast decimal to integer. always use overflow check to decide nullable
140
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
141
    requires(IsDataTypeInt<ToDataType> && IsDataTypeDecimal<FromDataType>)
142
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
143
public:
144
    Status execute_impl(RuntimeState* /*state*/, const ColumnWithTypeAndName& source_column,
145
                        ColumnWithTypeAndName& target_column, size_t input_rows_count,
146
380
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
380
        using ToFieldType = typename ToDataType::FieldType;
148
149
380
        const ColumnWithTypeAndName& named_from = source_column;
150
380
        const auto* col_from =
151
380
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
380
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
380
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
380
        UInt32 from_precision = from_decimal_type.get_precision();
159
380
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
380
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
380
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
380
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
380
        const auto& vec_from = col_from->get_data();
170
380
        const auto* vec_from_data = vec_from.data();
171
380
        auto& vec_to = col_to->get_data();
172
380
        auto* vec_to_data = vec_to.data();
173
174
380
        ColumnUInt8::MutablePtr col_null_map_to;
175
380
        NullMap::value_type* null_map_data = nullptr;
176
380
        if (overflow_and_nullable) {
177
146
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
146
            null_map_data = col_null_map_to->get_data().data();
179
146
        }
180
181
380
        CastParameters params;
182
380
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
380
        size_t size = vec_from.size();
184
22.4k
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
22.1k
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
22.1k
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
22.1k
                                         typename ToDataType::FieldType>(
191
22.1k
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
22.1k
        }
199
200
380
        if (overflow_and_nullable) {
201
146
            target_column.column =
202
146
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
234
        } else {
204
234
            target_column.column = std::move(col_to);
205
234
        }
206
380
        return Status::OK();
207
380
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
302
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
295
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
295
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
295
                                         typename ToDataType::FieldType>(
191
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
295
        }
199
200
7
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
302
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
295
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
295
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
295
                                         typename ToDataType::FieldType>(
191
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
295
        }
199
200
7
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_3EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
302
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
295
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
295
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
295
                                         typename ToDataType::FieldType>(
191
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
295
        }
199
200
7
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
302
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
295
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
295
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
295
                                         typename ToDataType::FieldType>(
191
295
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
295
        }
199
200
7
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_4EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
623
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
614
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
614
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
614
                                         typename ToDataType::FieldType>(
191
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
614
        }
199
200
9
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
6
        } else {
204
6
            target_column.column = std::move(col_to);
205
6
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
623
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
614
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
614
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
614
                                         typename ToDataType::FieldType>(
191
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
614
        }
199
200
9
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
6
        } else {
204
6
            target_column.column = std::move(col_to);
205
6
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
148
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
144
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
144
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
144
                                         typename ToDataType::FieldType>(
191
144
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
144
        }
199
200
4
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
0
            target_column.column = std::move(col_to);
205
0
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
292
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
288
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
288
                                         typename ToDataType::FieldType>(
191
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
288
        }
199
200
4
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
292
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
288
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
288
                                         typename ToDataType::FieldType>(
191
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
288
        }
199
200
4
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
551
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
542
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
542
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
542
                                         typename ToDataType::FieldType>(
191
542
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
542
        }
199
200
9
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
5
            target_column.column = std::move(col_to);
205
5
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
4
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
4
            null_map_data = col_null_map_to->get_data().data();
179
4
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
551
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
542
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
542
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
542
                                         typename ToDataType::FieldType>(
191
542
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
542
        }
199
200
9
        if (overflow_and_nullable) {
201
4
            target_column.column =
202
4
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
5
            target_column.column = std::move(col_to);
205
5
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
5
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
5
            null_map_data = col_null_map_to->get_data().data();
179
5
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
479
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
470
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
470
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
470
                                         typename ToDataType::FieldType>(
191
470
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
470
        }
199
200
9
        if (overflow_and_nullable) {
201
5
            target_column.column =
202
5
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
5
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
7
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
7
        using ToFieldType = typename ToDataType::FieldType;
148
149
7
        const ColumnWithTypeAndName& named_from = source_column;
150
7
        const auto* col_from =
151
7
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
7
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
7
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
7
        UInt32 from_precision = from_decimal_type.get_precision();
159
7
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
7
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
7
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
7
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
7
        const auto& vec_from = col_from->get_data();
170
7
        const auto* vec_from_data = vec_from.data();
171
7
        auto& vec_to = col_to->get_data();
172
7
        auto* vec_to_data = vec_to.data();
173
174
7
        ColumnUInt8::MutablePtr col_null_map_to;
175
7
        NullMap::value_type* null_map_data = nullptr;
176
7
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
7
        CastParameters params;
182
7
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
7
        size_t size = vec_from.size();
184
455
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
448
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
448
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
448
                                         typename ToDataType::FieldType>(
191
448
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
448
        }
199
200
7
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
7
        } else {
204
7
            target_column.column = std::move(col_to);
205
7
        }
206
7
        return Status::OK();
207
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
292
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
288
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
288
                                         typename ToDataType::FieldType>(
191
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
288
        }
199
200
4
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
4
        using ToFieldType = typename ToDataType::FieldType;
148
149
4
        const ColumnWithTypeAndName& named_from = source_column;
150
4
        const auto* col_from =
151
4
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
4
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
4
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
4
        UInt32 from_precision = from_decimal_type.get_precision();
159
4
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
4
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
4
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
4
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
4
        const auto& vec_from = col_from->get_data();
170
4
        const auto* vec_from_data = vec_from.data();
171
4
        auto& vec_to = col_to->get_data();
172
4
        auto* vec_to_data = vec_to.data();
173
174
4
        ColumnUInt8::MutablePtr col_null_map_to;
175
4
        NullMap::value_type* null_map_data = nullptr;
176
4
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
4
        CastParameters params;
182
4
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
4
        size_t size = vec_from.size();
184
292
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
288
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
288
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
288
                                         typename ToDataType::FieldType>(
191
288
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
288
        }
199
200
4
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
4
        } else {
204
4
            target_column.column = std::move(col_to);
205
4
        }
206
4
        return Status::OK();
207
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
0
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
0
            null_map_data = col_null_map_to->get_data().data();
179
0
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
713
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
704
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
704
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
704
                                         typename ToDataType::FieldType>(
191
704
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
704
        }
199
200
9
        if (overflow_and_nullable) {
201
0
            target_column.column =
202
0
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
9
        } else {
204
9
            target_column.column = std::move(col_to);
205
9
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
623
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
614
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
614
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
614
                                         typename ToDataType::FieldType>(
191
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
614
        }
199
200
9
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
6
        } else {
204
6
            target_column.column = std::move(col_to);
205
6
        }
206
9
        return Status::OK();
207
9
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEENS_14DataTypeNumberILS3_7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERSA_mPKh
Line
Count
Source
146
9
                        const NullMap::value_type* parent_null_map = nullptr) const override {
147
9
        using ToFieldType = typename ToDataType::FieldType;
148
149
9
        const ColumnWithTypeAndName& named_from = source_column;
150
9
        const auto* col_from =
151
9
                check_and_get_column<typename FromDataType::ColumnType>(named_from.column.get());
152
9
        if (!col_from) {
153
0
            return Status::InternalError(fmt::format("Column type mismatch: expected {}, got {}",
154
0
                                                     type_to_string(FromDataType::PType),
155
0
                                                     named_from.column->get_name()));
156
0
        }
157
9
        const auto& from_decimal_type = assert_cast<const FromDataType&>(*named_from.type);
158
9
        UInt32 from_precision = from_decimal_type.get_precision();
159
9
        UInt32 from_scale = from_decimal_type.get_scale();
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
        constexpr UInt32 to_max_digits = NumberTraits::max_ascii_len<ToFieldType>();
164
9
        bool overflow_and_nullable = (from_precision - from_scale) >= to_max_digits;
165
        // only in non-strict mode and may overflow, we set nullable
166
9
        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && overflow_and_nullable;
167
168
9
        auto col_to = ToDataType::ColumnType::create(input_rows_count);
169
9
        const auto& vec_from = col_from->get_data();
170
9
        const auto* vec_from_data = vec_from.data();
171
9
        auto& vec_to = col_to->get_data();
172
9
        auto* vec_to_data = vec_to.data();
173
174
9
        ColumnUInt8::MutablePtr col_null_map_to;
175
9
        NullMap::value_type* null_map_data = nullptr;
176
9
        if (overflow_and_nullable) {
177
3
            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
178
3
            null_map_data = col_null_map_to->get_data().data();
179
3
        }
180
181
9
        CastParameters params;
182
9
        params.is_strict = (CastMode == CastModeType::StrictMode);
183
9
        size_t size = vec_from.size();
184
623
        for (size_t i = 0; i < size; i++) {
185
            // Skip hidden payload of rows marked as null by the input null map.
186
614
            if (parent_null_map && parent_null_map[i]) {
187
0
                continue;
188
0
            }
189
614
            if (!CastToInt::from_decimal<typename FromDataType::FieldType,
190
614
                                         typename ToDataType::FieldType>(
191
614
                        vec_from_data[i], from_precision, from_scale, vec_to_data[i], params)) {
192
0
                if (set_nullable) {
193
0
                    null_map_data[i] = 1;
194
0
                } else {
195
0
                    return params.status;
196
0
                }
197
0
            }
198
614
        }
199
200
9
        if (overflow_and_nullable) {
201
3
            target_column.column =
202
3
                    ColumnNullable::create(std::move(col_to), std::move(col_null_map_to));
203
6
        } else {
204
6
            target_column.column = std::move(col_to);
205
6
        }
206
9
        return Status::OK();
207
9
    }
208
};
209
210
template <typename T>
211
constexpr static bool int_allow_cast_from_date =
212
        std::is_same_v<T, DataTypeInt32> || std::is_same_v<T, DataTypeInt64> ||
213
        std::is_same_v<T, DataTypeInt128>;
214
215
template <typename T>
216
constexpr static bool int_allow_cast_from_datetime =
217
        std::is_same_v<T, DataTypeInt64> || std::is_same_v<T, DataTypeInt128>;
218
219
// cast from date and datetime to int
220
template <CastModeType CastMode, typename FromDataType, typename ToDataType>
221
    requires(((IsDateType<FromDataType> ||
222
               IsDateV2Type<FromDataType>)&&int_allow_cast_from_date<ToDataType>) ||
223
             ((IsDateTimeType<FromDataType> || IsDateTimeV2Type<FromDataType> ||
224
               std::is_same_v<FromDataType,
225
                              DataTypeTimeStampNs>)&&int_allow_cast_from_datetime<ToDataType>))
226
class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
227
public:
228
    Status execute_impl(RuntimeState* state, const ColumnWithTypeAndName& source_column,
229
                        ColumnWithTypeAndName& target_column, size_t input_rows_count,
230
24
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
24
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
24
                state, source_column, target_column, input_rows_count, parent_null_map);
233
24
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
4
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
4
                state, source_column, target_column, input_rows_count, parent_null_map);
233
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
4
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
4
                state, source_column, target_column, input_rows_count, parent_null_map);
233
4
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_19DataTypeTimeStampNsENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_19DataTypeTimeStampNsENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeDateENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeDateV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
4
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
4
                state, source_column, target_column, input_rows_count, parent_null_map);
233
4
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_18DataTypeDateTimeV2ENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
4
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
4
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
4
                state, source_column, target_column, input_rows_count, parent_null_map);
233
4
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_19DataTypeTimeStampNsENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_19DataTypeTimeStampNsENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Line
Count
Source
230
1
                        const NullMap::value_type* parent_null_map = nullptr) const override {
231
1
        return static_cast_no_overflow<FromDataType, ToDataType>(
232
1
                state, source_column, target_column, input_rows_count, parent_null_map);
233
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_16DataTypeDateTimeENS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEE12execute_implEPNS_12RuntimeStateERKNS_21ColumnWithTypeAndNameERS9_mPKh
234
};
235
} // namespace doris