Coverage Report

Created: 2026-03-15 17:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/cast_to_ip.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 "core/column/column_nullable.h"
21
#include "core/data_type/data_type_ipv4.h"
22
#include "core/data_type/primitive_type.h"
23
#include "exprs/function/cast/cast_base.h"
24
25
namespace doris {
26
#include "common/compile_check_begin.h"
27
28
struct CastToIPv4 {
29
    static bool from_string(const StringRef& from, IPv4& to, CastParameters&);
30
};
31
32
48
inline bool CastToIPv4::from_string(const StringRef& from, IPv4& to, CastParameters&) {
33
48
    return IPv4Value::from_string(to, from.data, from.size);
34
48
}
35
36
struct CastToIPv6 {
37
    static bool from_string(const StringRef& from, IPv6& to, CastParameters&);
38
    static bool from_ipv4(const IPv4& from, IPv6& to, CastParameters&);
39
};
40
41
51
inline bool CastToIPv6::from_string(const StringRef& from, IPv6& to, CastParameters&) {
42
51
    return IPv6Value::from_string(to, from.data, from.size);
43
51
}
44
45
4
inline bool CastToIPv6::from_ipv4(const IPv4& from, IPv6& to, CastParameters&) {
46
4
    map_ipv4_to_ipv6(from, reinterpret_cast<UInt8*>(&to));
47
4
    return true;
48
4
}
49
50
template <CastModeType Mode, typename IpDataType>
51
    requires(IsIPType<IpDataType>)
52
class CastToImpl<Mode, DataTypeString, IpDataType> : public CastToBase {
53
public:
54
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
55
                        uint32_t result, size_t input_rows_count,
56
16
                        const NullMap::value_type* null_map = nullptr) const override {
57
16
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
58
16
                block.get_by_position(arguments[0]).column.get());
59
60
16
        auto to_type = block.get_by_position(result).type;
61
16
        auto serde = remove_nullable(to_type)->get_serde();
62
63
        // by default framework, to_type is already unwrapped nullable
64
16
        MutableColumnPtr column_to = to_type->create_column();
65
16
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
66
16
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
67
68
16
        if constexpr (Mode == CastModeType::NonStrictMode) {
69
            // may write nulls to nullable_col_to
70
4
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
71
12
        } else if constexpr (Mode == CastModeType::StrictMode) {
72
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
73
12
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
74
12
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
75
        } else {
76
            return Status::InternalError("Unsupported cast mode");
77
        }
78
79
6
        block.get_by_position(result).column = std::move(nullable_col_to);
80
16
        return Status::OK();
81
16
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_12DataTypeIPv4EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
56
5
                        const NullMap::value_type* null_map = nullptr) const override {
57
5
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
58
5
                block.get_by_position(arguments[0]).column.get());
59
60
5
        auto to_type = block.get_by_position(result).type;
61
5
        auto serde = remove_nullable(to_type)->get_serde();
62
63
        // by default framework, to_type is already unwrapped nullable
64
5
        MutableColumnPtr column_to = to_type->create_column();
65
5
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
66
5
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
67
68
        if constexpr (Mode == CastModeType::NonStrictMode) {
69
            // may write nulls to nullable_col_to
70
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
71
5
        } else if constexpr (Mode == CastModeType::StrictMode) {
72
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
73
5
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
74
5
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
75
        } else {
76
            return Status::InternalError("Unsupported cast mode");
77
        }
78
79
1
        block.get_by_position(result).column = std::move(nullable_col_to);
80
5
        return Status::OK();
81
5
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_12DataTypeIPv4EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
56
2
                        const NullMap::value_type* null_map = nullptr) const override {
57
2
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
58
2
                block.get_by_position(arguments[0]).column.get());
59
60
2
        auto to_type = block.get_by_position(result).type;
61
2
        auto serde = remove_nullable(to_type)->get_serde();
62
63
        // by default framework, to_type is already unwrapped nullable
64
2
        MutableColumnPtr column_to = to_type->create_column();
65
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
66
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
67
68
2
        if constexpr (Mode == CastModeType::NonStrictMode) {
69
            // may write nulls to nullable_col_to
70
2
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
71
        } else if constexpr (Mode == CastModeType::StrictMode) {
72
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
73
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
74
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
75
        } else {
76
            return Status::InternalError("Unsupported cast mode");
77
        }
78
79
2
        block.get_by_position(result).column = std::move(nullable_col_to);
80
2
        return Status::OK();
81
2
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_14DataTypeStringENS_12DataTypeIPv6EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
56
7
                        const NullMap::value_type* null_map = nullptr) const override {
57
7
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
58
7
                block.get_by_position(arguments[0]).column.get());
59
60
7
        auto to_type = block.get_by_position(result).type;
61
7
        auto serde = remove_nullable(to_type)->get_serde();
62
63
        // by default framework, to_type is already unwrapped nullable
64
7
        MutableColumnPtr column_to = to_type->create_column();
65
7
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
66
7
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
67
68
        if constexpr (Mode == CastModeType::NonStrictMode) {
69
            // may write nulls to nullable_col_to
70
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
71
7
        } else if constexpr (Mode == CastModeType::StrictMode) {
72
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
73
7
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
74
7
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
75
        } else {
76
            return Status::InternalError("Unsupported cast mode");
77
        }
78
79
1
        block.get_by_position(result).column = std::move(nullable_col_to);
80
7
        return Status::OK();
81
7
    }
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_14DataTypeStringENS_12DataTypeIPv6EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
56
2
                        const NullMap::value_type* null_map = nullptr) const override {
57
2
        const auto* col_from = check_and_get_column<DataTypeString::ColumnType>(
58
2
                block.get_by_position(arguments[0]).column.get());
59
60
2
        auto to_type = block.get_by_position(result).type;
61
2
        auto serde = remove_nullable(to_type)->get_serde();
62
63
        // by default framework, to_type is already unwrapped nullable
64
2
        MutableColumnPtr column_to = to_type->create_column();
65
2
        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
66
2
                std::move(column_to), ColumnUInt8::create(input_rows_count, 0));
67
68
2
        if constexpr (Mode == CastModeType::NonStrictMode) {
69
            // may write nulls to nullable_col_to
70
2
            RETURN_IF_ERROR(serde->from_string_batch(*col_from, *nullable_col_to, {}));
71
        } else if constexpr (Mode == CastModeType::StrictMode) {
72
            // WON'T write nulls to nullable_col_to, just raise errors. null_map is only used to skip invalid rows
73
            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
74
                    *col_from, nullable_col_to->get_nested_column(), {}, null_map));
75
        } else {
76
            return Status::InternalError("Unsupported cast mode");
77
        }
78
79
2
        block.get_by_position(result).column = std::move(nullable_col_to);
80
2
        return Status::OK();
81
2
    }
82
};
83
84
template <CastModeType AllMode>
85
class CastToImpl<AllMode, DataTypeIPv4, DataTypeIPv6> : public CastToBase {
86
public:
87
    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
88
                        uint32_t result, size_t input_rows_count,
89
1
                        const NullMap::value_type* null_map = nullptr) const override {
90
1
        const auto* col_from = check_and_get_column<DataTypeIPv4::ColumnType>(
91
1
                block.get_by_position(arguments[0]).column.get());
92
1
        const auto size = col_from->size();
93
1
        auto col_to = DataTypeIPv6::ColumnType::create(size);
94
1
        auto& to_data = col_to->get_data();
95
1
        const auto& from_data = col_from->get_data();
96
1
        CastParameters params;
97
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
98
99
5
        for (size_t i = 0; i < size; ++i) {
100
4
            CastToIPv6::from_ipv4(from_data[i], to_data[i], params);
101
4
        }
102
103
1
        block.get_by_position(result).column = std::move(col_to);
104
1
        return Status::OK();
105
1
    }
Unexecuted instantiation: _ZNK5doris10CastToImplILNS_12CastModeTypeE0ENS_12DataTypeIPv4ENS_12DataTypeIPv6EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
_ZNK5doris10CastToImplILNS_12CastModeTypeE1ENS_12DataTypeIPv4ENS_12DataTypeIPv6EE12execute_implEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKh
Line
Count
Source
89
1
                        const NullMap::value_type* null_map = nullptr) const override {
90
1
        const auto* col_from = check_and_get_column<DataTypeIPv4::ColumnType>(
91
1
                block.get_by_position(arguments[0]).column.get());
92
1
        const auto size = col_from->size();
93
1
        auto col_to = DataTypeIPv6::ColumnType::create(size);
94
1
        auto& to_data = col_to->get_data();
95
1
        const auto& from_data = col_from->get_data();
96
1
        CastParameters params;
97
1
        params.is_strict = (AllMode == CastModeType::StrictMode);
98
99
5
        for (size_t i = 0; i < size; ++i) {
100
4
            CastToIPv6::from_ipv4(from_data[i], to_data[i], params);
101
4
        }
102
103
1
        block.get_by_position(result).column = std::move(col_to);
104
1
        return Status::OK();
105
1
    }
106
};
107
108
namespace CastWrapper {
109
110
template <typename IpType>
111
    requires(std::is_same_v<IpType, DataTypeIPv4> || std::is_same_v<IpType, DataTypeIPv6>)
112
17
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
113
17
    std::shared_ptr<CastToBase> cast_to_ip;
114
115
17
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
17
        using Types = std::decay_t<decltype(types)>;
117
17
        using FromDataType = typename Types::LeftType;
118
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
17
                      IsIPType<FromDataType>) {
120
17
            if (context->enable_strict_mode()) {
121
12
                cast_to_ip = std::make_shared<
122
12
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
12
            } else {
124
5
                cast_to_ip = std::make_shared<
125
5
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
5
            }
127
17
            return true;
128
17
        } else {
129
0
            return false;
130
0
        }
131
17
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairIS2_vEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairIS4_vEEEEbSR_
_ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSR_
Line
Count
Source
115
7
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
7
        using Types = std::decay_t<decltype(types)>;
117
7
        using FromDataType = typename Types::LeftType;
118
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
7
                      IsIPType<FromDataType>) {
120
7
            if (context->enable_strict_mode()) {
121
5
                cast_to_ip = std::make_shared<
122
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
5
            } else {
124
2
                cast_to_ip = std::make_shared<
125
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
2
            }
127
7
            return true;
128
        } else {
129
            return false;
130
        }
131
7
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_12DataTypeDateEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeDateV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbSR_
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbSR_
_ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairIS4_vEEEEbSR_
Line
Count
Source
115
1
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
1
        using Types = std::decay_t<decltype(types)>;
117
1
        using FromDataType = typename Types::LeftType;
118
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
1
                      IsIPType<FromDataType>) {
120
1
            if (context->enable_strict_mode()) {
121
0
                cast_to_ip = std::make_shared<
122
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
1
            } else {
124
1
                cast_to_ip = std::make_shared<
125
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
1
            }
127
1
            return true;
128
        } else {
129
            return false;
130
        }
131
1
    };
Unexecuted instantiation: _ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairIS2_vEEEEbSR_
_ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlRKS3_E_clINS_8TypePairINS_14DataTypeStringEvEEEEbSR_
Line
Count
Source
115
9
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
9
        using Types = std::decay_t<decltype(types)>;
117
9
        using FromDataType = typename Types::LeftType;
118
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
9
                      IsIPType<FromDataType>) {
120
9
            if (context->enable_strict_mode()) {
121
7
                cast_to_ip = std::make_shared<
122
7
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
7
            } else {
124
2
                cast_to_ip = std::make_shared<
125
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
2
            }
127
9
            return true;
128
        } else {
129
            return false;
130
        }
131
9
    };
132
133
17
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
134
0
        return create_unsupport_wrapper(
135
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
136
0
    }
137
138
17
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
139
17
                        uint32_t result, size_t input_rows_count,
140
17
                        const NullMap::value_type* null_map = nullptr) {
141
17
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
142
17
                                        null_map);
143
17
    };
_ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS8_SA_SF_jmSH_E_clES8_SA_SF_jmSH_
Line
Count
Source
140
7
                        const NullMap::value_type* null_map = nullptr) {
141
7
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
142
7
                                        null_map);
143
7
    };
_ZZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEEENKUlS8_SA_SF_jmSH_E_clES8_SA_SF_jmSH_
Line
Count
Source
140
10
                        const NullMap::value_type* null_map = nullptr) {
141
10
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
142
10
                                        null_map);
143
10
    };
144
17
}
_ZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
112
7
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
113
7
    std::shared_ptr<CastToBase> cast_to_ip;
114
115
7
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
7
        using Types = std::decay_t<decltype(types)>;
117
7
        using FromDataType = typename Types::LeftType;
118
7
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
7
                      IsIPType<FromDataType>) {
120
7
            if (context->enable_strict_mode()) {
121
7
                cast_to_ip = std::make_shared<
122
7
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
7
            } else {
124
7
                cast_to_ip = std::make_shared<
125
7
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
7
            }
127
7
            return true;
128
7
        } else {
129
7
            return false;
130
7
        }
131
7
    };
132
133
7
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
134
0
        return create_unsupport_wrapper(
135
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
136
0
    }
137
138
7
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
139
7
                        uint32_t result, size_t input_rows_count,
140
7
                        const NullMap::value_type* null_map = nullptr) {
141
7
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
142
7
                                        null_map);
143
7
    };
144
7
}
_ZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
112
10
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
113
10
    std::shared_ptr<CastToBase> cast_to_ip;
114
115
10
    auto make_ip_wrapper = [&](const auto& types) -> bool {
116
10
        using Types = std::decay_t<decltype(types)>;
117
10
        using FromDataType = typename Types::LeftType;
118
10
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
119
10
                      IsIPType<FromDataType>) {
120
10
            if (context->enable_strict_mode()) {
121
10
                cast_to_ip = std::make_shared<
122
10
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
123
10
            } else {
124
10
                cast_to_ip = std::make_shared<
125
10
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
126
10
            }
127
10
            return true;
128
10
        } else {
129
10
            return false;
130
10
        }
131
10
    };
132
133
10
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
134
0
        return create_unsupport_wrapper(
135
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
136
0
    }
137
138
10
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
139
10
                        uint32_t result, size_t input_rows_count,
140
10
                        const NullMap::value_type* null_map = nullptr) {
141
10
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
142
10
                                        null_map);
143
10
    };
144
10
}
145
#include "common/compile_check_end.h"
146
}; // namespace CastWrapper
147
148
} // namespace doris