Coverage Report

Created: 2026-03-13 19:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/storage/predicate/predicate_creator.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 "storage/predicate/predicate_creator.h"
19
20
namespace doris {
21
22
std::shared_ptr<ColumnPredicate> create_bloom_filter_predicate(
23
        const uint32_t cid, const std::string col_name, const DataTypePtr& data_type,
24
0
        const std::shared_ptr<BloomFilterFuncBase>& filter) {
25
    // Do the necessary type conversion, for CAST(STRING AS CHAR), we do nothing here but change the data type to the target type CHAR
26
0
    std::shared_ptr<BloomFilterFuncBase> filter_olap;
27
0
    filter_olap.reset(create_bloom_filter(data_type->get_primitive_type(), false));
28
0
    filter_olap->light_copy(filter.get());
29
0
    switch (data_type->get_primitive_type()) {
30
0
    case TYPE_TINYINT: {
31
0
        return BloomFilterColumnPredicate<TYPE_TINYINT>::create_shared(cid, col_name, filter_olap);
32
0
    }
33
0
    case TYPE_SMALLINT: {
34
0
        return BloomFilterColumnPredicate<TYPE_SMALLINT>::create_shared(cid, col_name, filter_olap);
35
0
    }
36
0
    case TYPE_INT: {
37
0
        return BloomFilterColumnPredicate<TYPE_INT>::create_shared(cid, col_name, filter_olap);
38
0
    }
39
0
    case TYPE_BIGINT: {
40
0
        return BloomFilterColumnPredicate<TYPE_BIGINT>::create_shared(cid, col_name, filter_olap);
41
0
    }
42
0
    case TYPE_LARGEINT: {
43
0
        return BloomFilterColumnPredicate<TYPE_LARGEINT>::create_shared(cid, col_name, filter_olap);
44
0
    }
45
0
    case TYPE_FLOAT: {
46
0
        return BloomFilterColumnPredicate<TYPE_FLOAT>::create_shared(cid, col_name, filter_olap);
47
0
    }
48
0
    case TYPE_DOUBLE: {
49
0
        return BloomFilterColumnPredicate<TYPE_DOUBLE>::create_shared(cid, col_name, filter_olap);
50
0
    }
51
0
    case TYPE_DECIMALV2: {
52
0
        return BloomFilterColumnPredicate<TYPE_DECIMALV2>::create_shared(cid, col_name,
53
0
                                                                         filter_olap);
54
0
    }
55
0
    case TYPE_DECIMAL32: {
56
0
        return BloomFilterColumnPredicate<TYPE_DECIMAL32>::create_shared(cid, col_name,
57
0
                                                                         filter_olap);
58
0
    }
59
0
    case TYPE_DECIMAL64: {
60
0
        return BloomFilterColumnPredicate<TYPE_DECIMAL64>::create_shared(cid, col_name,
61
0
                                                                         filter_olap);
62
0
    }
63
0
    case TYPE_DECIMAL128I: {
64
0
        return BloomFilterColumnPredicate<TYPE_DECIMAL128I>::create_shared(cid, col_name,
65
0
                                                                           filter_olap);
66
0
    }
67
0
    case TYPE_DECIMAL256: {
68
0
        return BloomFilterColumnPredicate<TYPE_DECIMAL256>::create_shared(cid, col_name,
69
0
                                                                          filter_olap);
70
0
    }
71
0
    case TYPE_CHAR: {
72
0
        return BloomFilterColumnPredicate<TYPE_CHAR>::create_shared(cid, col_name, filter_olap);
73
0
    }
74
0
    case TYPE_VARCHAR: {
75
0
        return BloomFilterColumnPredicate<TYPE_VARCHAR>::create_shared(cid, col_name, filter_olap);
76
0
    }
77
0
    case TYPE_STRING: {
78
0
        return BloomFilterColumnPredicate<TYPE_STRING>::create_shared(cid, col_name, filter_olap);
79
0
    }
80
0
    case TYPE_DATE: {
81
0
        return BloomFilterColumnPredicate<TYPE_DATE>::create_shared(cid, col_name, filter_olap);
82
0
    }
83
0
    case TYPE_DATEV2: {
84
0
        return BloomFilterColumnPredicate<TYPE_DATEV2>::create_shared(cid, col_name, filter_olap);
85
0
    }
86
0
    case TYPE_DATETIME: {
87
0
        return BloomFilterColumnPredicate<TYPE_DATETIME>::create_shared(cid, col_name, filter_olap);
88
0
    }
89
0
    case TYPE_DATETIMEV2: {
90
0
        return BloomFilterColumnPredicate<TYPE_DATETIMEV2>::create_shared(cid, col_name,
91
0
                                                                          filter_olap);
92
0
    }
93
0
    case TYPE_TIMESTAMPTZ: {
94
0
        return BloomFilterColumnPredicate<TYPE_TIMESTAMPTZ>::create_shared(cid, col_name,
95
0
                                                                           filter_olap);
96
0
    }
97
0
    case TYPE_BOOLEAN: {
98
0
        return BloomFilterColumnPredicate<TYPE_BOOLEAN>::create_shared(cid, col_name, filter_olap);
99
0
    }
100
0
    case TYPE_IPV4: {
101
0
        return BloomFilterColumnPredicate<TYPE_IPV4>::create_shared(cid, col_name, filter_olap);
102
0
    }
103
0
    case TYPE_IPV6: {
104
0
        return BloomFilterColumnPredicate<TYPE_IPV6>::create_shared(cid, col_name, filter_olap);
105
0
    }
106
0
    default:
107
0
        throw Exception(ErrorCode::INVALID_ARGUMENT,
108
0
                        fmt::format("Cannot use bloom filter for type: {}",
109
0
                                    type_to_string(data_type->get_primitive_type())));
110
0
        return nullptr;
111
0
    }
112
0
}
113
114
std::shared_ptr<ColumnPredicate> create_bitmap_filter_predicate(
115
        const uint32_t cid, const std::string col_name, const DataTypePtr& data_type,
116
0
        const std::shared_ptr<BitmapFilterFuncBase>& filter) {
117
0
    switch (data_type->get_primitive_type()) {
118
0
    case TYPE_TINYINT: {
119
0
        return BitmapFilterColumnPredicate<TYPE_TINYINT>::create_shared(cid, col_name, filter);
120
0
    }
121
0
    case TYPE_SMALLINT: {
122
0
        return BitmapFilterColumnPredicate<TYPE_SMALLINT>::create_shared(cid, col_name, filter);
123
0
    }
124
0
    case TYPE_INT: {
125
0
        return BitmapFilterColumnPredicate<TYPE_INT>::create_shared(cid, col_name, filter);
126
0
    }
127
0
    case TYPE_BIGINT: {
128
0
        return BitmapFilterColumnPredicate<TYPE_BIGINT>::create_shared(cid, col_name, filter);
129
0
    }
130
0
    default:
131
0
        throw Exception(ErrorCode::INVALID_ARGUMENT,
132
0
                        fmt::format("Cannot use bitmap filter for type: {}",
133
0
                                    type_to_string(data_type->get_primitive_type())));
134
0
        return nullptr;
135
0
    }
136
0
}
137
138
} // namespace doris