Coverage Report

Created: 2026-04-02 14:19

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