Coverage Report

Created: 2026-07-02 14:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/function/cast/function_cast_bool.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
#include "exprs/function/cast/cast_to_boolean.h"
19
20
namespace doris::CastWrapper {
21
22
64
WrapperType create_boolean_wrapper(FunctionContext* context, const DataTypePtr& from_type) {
23
64
    std::shared_ptr<CastToBase> cast_to_bool;
24
25
64
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
64
        using Types = std::decay_t<decltype(types)>;
27
64
        using FromDataType = typename Types::LeftType;
28
64
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
64
            if (context->enable_strict_mode()) {
30
42
                cast_to_bool = std::make_shared<
31
42
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
42
            } else {
33
22
                cast_to_bool = std::make_shared<
34
22
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
22
            }
36
64
            return true;
37
64
        } else {
38
0
            return false;
39
0
        }
40
64
    };
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE2EEEvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE3EEEvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE4EEEvEEEEbRKT_
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE5EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE6EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE7EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE8EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeNumberILNS_13PrimitiveTypeE9EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE28EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE29EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE20EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE30EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_15DataTypeDecimalILNS_13PrimitiveTypeE35EEEvEEEEbRKT_
Line
Count
Source
25
4
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
4
        using Types = std::decay_t<decltype(types)>;
27
4
        using FromDataType = typename Types::LeftType;
28
4
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
4
            if (context->enable_strict_mode()) {
30
2
                cast_to_bool = std::make_shared<
31
2
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
2
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
4
            return true;
37
        } else {
38
            return false;
39
        }
40
4
    };
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_12DataTypeDateEvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeDateV2EvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_18DataTypeDateTimeV2EvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_16DataTypeDateTimeEvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeTimeV2EvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_19DataTypeTimeStampTzEvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_12DataTypeIPv4EvEEEEbRKT_
Unexecuted instantiation: function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_12DataTypeIPv6EvEEEEbRKT_
function_cast_bool.cpp:_ZZN5doris11CastWrapper22create_boolean_wrapperEPNS_15FunctionContextERKSt10shared_ptrIKNS_9IDataTypeEEENK3$_1clINS_8TypePairINS_14DataTypeStringEvEEEEbRKT_
Line
Count
Source
25
24
    auto make_bool_wrapper = [&](const auto& types) -> bool {
26
24
        using Types = std::decay_t<decltype(types)>;
27
24
        using FromDataType = typename Types::LeftType;
28
24
        if constexpr (CastUtil::IsBaseCastFromType<FromDataType>) {
29
24
            if (context->enable_strict_mode()) {
30
22
                cast_to_bool = std::make_shared<
31
22
                        CastToImpl<CastModeType::StrictMode, FromDataType, DataTypeBool>>();
32
22
            } else {
33
2
                cast_to_bool = std::make_shared<
34
2
                        CastToImpl<CastModeType::NonStrictMode, FromDataType, DataTypeBool>>();
35
2
            }
36
24
            return true;
37
        } else {
38
            return false;
39
        }
40
24
    };
41
42
64
    if (!call_on_index_and_data_type<void>(from_type->get_primitive_type(), make_bool_wrapper)) {
43
0
        return create_unsupport_wrapper(
44
0
                fmt::format("CAST AS bool not supported {}", from_type->get_name()));
45
0
    }
46
47
64
    return [cast_to_bool](FunctionContext* context, Block& block, const ColumnNumbers& arguments,
48
64
                          uint32_t result, size_t input_rows_count,
49
64
                          const NullMap::value_type* null_map = nullptr) {
50
64
        return cast_to_bool->execute_impl(context, block, arguments, result, input_rows_count,
51
64
                                          null_map);
52
64
    };
53
64
}
54
55
} // namespace doris::CastWrapper