Coverage Report

Created: 2026-04-02 18:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/function_cast_ip.cpp
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
// This translation unit is the ONLY place that includes cast_to_ip.h.
19
// All CastToImpl<CastMode, From, ToIpType> template instantiations are
20
// confined here, keeping them out of function_cast.cpp.
21
22
#include "core/data_type/data_type_ipv4.h"
23
#include "core/data_type/data_type_ipv6.h"
24
#include "exprs/function/cast/cast_base.h"
25
#include "exprs/function/cast/cast_to_ip.h"
26
27
namespace doris::CastWrapper {
28
29
template <typename IpType>
30
    requires(std::is_same_v<IpType, DataTypeIPv4> || std::is_same_v<IpType, DataTypeIPv6>)
31
17
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
32
17
    std::shared_ptr<CastToBase> cast_to_ip;
33
34
17
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
17
        using Types = std::decay_t<decltype(types)>;
36
17
        using FromDataType = typename Types::LeftType;
37
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
17
                      IsIPType<FromDataType>) {
39
17
            if (context->enable_strict_mode()) {
40
12
                cast_to_ip = std::make_shared<
41
12
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
12
            } else {
43
5
                cast_to_ip = std::make_shared<
44
5
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
5
            }
46
17
            return true;
47
17
        } else {
48
0
            return false;
49
0
        }
50
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
34
7
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
7
        using Types = std::decay_t<decltype(types)>;
36
7
        using FromDataType = typename Types::LeftType;
37
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
7
                      IsIPType<FromDataType>) {
39
7
            if (context->enable_strict_mode()) {
40
5
                cast_to_ip = std::make_shared<
41
5
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
5
            } else {
43
2
                cast_to_ip = std::make_shared<
44
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
2
            }
46
7
            return true;
47
        } else {
48
            return false;
49
        }
50
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
34
1
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
1
        using Types = std::decay_t<decltype(types)>;
36
1
        using FromDataType = typename Types::LeftType;
37
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
1
                      IsIPType<FromDataType>) {
39
1
            if (context->enable_strict_mode()) {
40
0
                cast_to_ip = std::make_shared<
41
0
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
1
            } else {
43
1
                cast_to_ip = std::make_shared<
44
1
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
1
            }
46
1
            return true;
47
        } else {
48
            return false;
49
        }
50
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
34
9
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
9
        using Types = std::decay_t<decltype(types)>;
36
9
        using FromDataType = typename Types::LeftType;
37
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
9
                      IsIPType<FromDataType>) {
39
9
            if (context->enable_strict_mode()) {
40
7
                cast_to_ip = std::make_shared<
41
7
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
7
            } else {
43
2
                cast_to_ip = std::make_shared<
44
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
2
            }
46
9
            return true;
47
        } else {
48
            return false;
49
        }
50
9
    };
51
52
17
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
53
0
        return create_unsupport_wrapper(
54
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
55
0
    }
56
57
17
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
58
17
                        uint32_t result, size_t input_rows_count,
59
17
                        const NullMap::value_type* null_map = nullptr) {
60
17
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
61
17
                                        null_map);
62
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
59
7
                        const NullMap::value_type* null_map = nullptr) {
60
7
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
61
7
                                        null_map);
62
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
59
10
                        const NullMap::value_type* null_map = nullptr) {
60
10
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
61
10
                                        null_map);
62
10
    };
63
17
}
_ZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv4EQoosr3stdE9is_same_vIT_S2_Esr3stdE9is_same_vIS3_NS_12DataTypeIPv6EEEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
31
7
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
32
7
    std::shared_ptr<CastToBase> cast_to_ip;
33
34
7
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
7
        using Types = std::decay_t<decltype(types)>;
36
7
        using FromDataType = typename Types::LeftType;
37
7
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
7
                      IsIPType<FromDataType>) {
39
7
            if (context->enable_strict_mode()) {
40
7
                cast_to_ip = std::make_shared<
41
7
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
7
            } else {
43
7
                cast_to_ip = std::make_shared<
44
7
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
7
            }
46
7
            return true;
47
7
        } else {
48
7
            return false;
49
7
        }
50
7
    };
51
52
7
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
53
0
        return create_unsupport_wrapper(
54
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
55
0
    }
56
57
7
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
58
7
                        uint32_t result, size_t input_rows_count,
59
7
                        const NullMap::value_type* null_map = nullptr) {
60
7
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
61
7
                                        null_map);
62
7
    };
63
7
}
_ZN5doris11CastWrapper17create_ip_wrapperINS_12DataTypeIPv6EQoosr3stdE9is_same_vIT_NS_12DataTypeIPv4EEsr3stdE9is_same_vIS3_S2_EEESt8functionIFNS_6StatusEPNS_15FunctionContextERNS_5BlockERKSt6vectorIjSaIjEEjmPKhEES8_RKSt10shared_ptrIKNS_9IDataTypeEE
Line
Count
Source
31
10
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
32
10
    std::shared_ptr<CastToBase> cast_to_ip;
33
34
10
    auto make_ip_wrapper = [&](const auto& types) -> bool {
35
10
        using Types = std::decay_t<decltype(types)>;
36
10
        using FromDataType = typename Types::LeftType;
37
10
        if constexpr (IsDataTypeNumber<FromDataType> || IsStringType<FromDataType> ||
38
10
                      IsIPType<FromDataType>) {
39
10
            if (context->enable_strict_mode()) {
40
10
                cast_to_ip = std::make_shared<
41
10
                        CastToImpl<CastModeType::StrictMode, FromDataType, IpType>>();
42
10
            } else {
43
10
                cast_to_ip = std::make_shared<
44
10
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, IpType>>();
45
10
            }
46
10
            return true;
47
10
        } else {
48
10
            return false;
49
10
        }
50
10
    };
51
52
10
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_ip_wrapper)) {
53
0
        return create_unsupport_wrapper(
54
0
                fmt::format("CAST AS ip not supported {}", from_type->get_name()));
55
0
    }
56
57
10
    return [cast_to_ip](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
58
10
                        uint32_t result, size_t input_rows_count,
59
10
                        const NullMap::value_type* null_map = nullptr) {
60
10
        return cast_to_ip->execute_impl(context, block, arguments, result, input_rows_count,
61
10
                                        null_map);
62
10
    };
63
10
}
64
65
WrapperType create_ip_wrapper(FunctionContext* context, const DataTypePtr& from_type,
66
17
                              PrimitiveType to_type) {
67
17
    switch (to_type) {
68
7
    case TYPE_IPV4:
69
7
        return create_ip_wrapper<DataTypeIPv4>(context, from_type);
70
10
    case TYPE_IPV6:
71
10
        return create_ip_wrapper<DataTypeIPv6>(context, from_type);
72
0
    default:
73
0
        return create_unsupport_wrapper(
74
0
                fmt::format("CAST AS ip: unsupported to_type {}", type_to_string(to_type)));
75
17
    }
76
17
}
77
78
} // namespace doris::CastWrapper