be/src/exprs/aggregate/aggregate_function_sequence_match.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/aggregate/aggregate_function_sequence_match.h" |
19 | | |
20 | | #include <boost/iterator/iterator_facade.hpp> |
21 | | |
22 | | #include "common/logging.h" |
23 | | #include "core/data_type/data_type.h" |
24 | | #include "exprs/aggregate/aggregate_function_simple_factory.h" |
25 | | #include "exprs/aggregate/helpers.h" |
26 | | |
27 | | namespace doris { |
28 | | #include "common/compile_check_begin.h" |
29 | | |
30 | | template <template <PrimitiveType> typename AggregateFunction> |
31 | | AggregateFunctionPtr create_aggregate_function_sequence_base(const std::string& name, |
32 | | const DataTypes& argument_types, |
33 | | const DataTypePtr& result_type, |
34 | | const bool result_is_nullable, |
35 | 15 | const AggregateFunctionAttr& attr) { |
36 | 15 | const auto arg_count = argument_types.size(); |
37 | | |
38 | 15 | if (arg_count < 4) { |
39 | 0 | LOG(WARNING) << "Aggregate function " + name + " requires at least 4 arguments."; |
40 | 0 | return nullptr; |
41 | 0 | } |
42 | 15 | if (arg_count - 2 > MAX_EVENTS) { |
43 | 0 | LOG(WARNING) << "Aggregate function " + name + " supports up to " + |
44 | 0 | std::to_string(MAX_EVENTS) + " event arguments."; |
45 | 0 | return nullptr; |
46 | 0 | } |
47 | | |
48 | 15 | switch (argument_types[1]->get_primitive_type()) { |
49 | 15 | case TYPE_DATETIMEV2: |
50 | 15 | return creator_without_type::create<AggregateFunction<TYPE_DATETIMEV2>>( |
51 | 15 | argument_types, result_is_nullable, attr); |
52 | 0 | case TYPE_DATEV2: |
53 | 0 | return creator_without_type::create<AggregateFunction<TYPE_DATEV2>>( |
54 | 0 | argument_types, result_is_nullable, attr); |
55 | 0 | default: |
56 | 0 | return nullptr; |
57 | 15 | } |
58 | 15 | } _ZN5doris39create_aggregate_function_sequence_baseINS_30AggregateFunctionSequenceMatchEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS2_IKNS_9IDataTypeEESaISG_EERKSG_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 35 | 7 | const AggregateFunctionAttr& attr) { | 36 | 7 | const auto arg_count = argument_types.size(); | 37 | | | 38 | 7 | if (arg_count < 4) { | 39 | 0 | LOG(WARNING) << "Aggregate function " + name + " requires at least 4 arguments."; | 40 | 0 | return nullptr; | 41 | 0 | } | 42 | 7 | if (arg_count - 2 > MAX_EVENTS) { | 43 | 0 | LOG(WARNING) << "Aggregate function " + name + " supports up to " + | 44 | 0 | std::to_string(MAX_EVENTS) + " event arguments."; | 45 | 0 | return nullptr; | 46 | 0 | } | 47 | | | 48 | 7 | switch (argument_types[1]->get_primitive_type()) { | 49 | 7 | case TYPE_DATETIMEV2: | 50 | 7 | return creator_without_type::create<AggregateFunction<TYPE_DATETIMEV2>>( | 51 | 7 | argument_types, result_is_nullable, attr); | 52 | 0 | case TYPE_DATEV2: | 53 | 0 | return creator_without_type::create<AggregateFunction<TYPE_DATEV2>>( | 54 | 0 | argument_types, result_is_nullable, attr); | 55 | 0 | default: | 56 | 0 | return nullptr; | 57 | 7 | } | 58 | 7 | } |
_ZN5doris39create_aggregate_function_sequence_baseINS_30AggregateFunctionSequenceCountEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS2_IKNS_9IDataTypeEESaISG_EERKSG_bRKNS_21AggregateFunctionAttrE Line | Count | Source | 35 | 8 | const AggregateFunctionAttr& attr) { | 36 | 8 | const auto arg_count = argument_types.size(); | 37 | | | 38 | 8 | if (arg_count < 4) { | 39 | 0 | LOG(WARNING) << "Aggregate function " + name + " requires at least 4 arguments."; | 40 | 0 | return nullptr; | 41 | 0 | } | 42 | 8 | if (arg_count - 2 > MAX_EVENTS) { | 43 | 0 | LOG(WARNING) << "Aggregate function " + name + " supports up to " + | 44 | 0 | std::to_string(MAX_EVENTS) + " event arguments."; | 45 | 0 | return nullptr; | 46 | 0 | } | 47 | | | 48 | 8 | switch (argument_types[1]->get_primitive_type()) { | 49 | 8 | case TYPE_DATETIMEV2: | 50 | 8 | return creator_without_type::create<AggregateFunction<TYPE_DATETIMEV2>>( | 51 | 8 | argument_types, result_is_nullable, attr); | 52 | 0 | case TYPE_DATEV2: | 53 | 0 | return creator_without_type::create<AggregateFunction<TYPE_DATEV2>>( | 54 | 0 | argument_types, result_is_nullable, attr); | 55 | 0 | default: | 56 | 0 | return nullptr; | 57 | 8 | } | 58 | 8 | } |
|
59 | | |
60 | 1 | void register_aggregate_function_sequence_match(AggregateFunctionSimpleFactory& factory) { |
61 | 1 | factory.register_function_both( |
62 | 1 | "sequence_match", |
63 | 1 | create_aggregate_function_sequence_base<AggregateFunctionSequenceMatch>); |
64 | 1 | factory.register_function_both( |
65 | 1 | "sequence_count", |
66 | 1 | create_aggregate_function_sequence_base<AggregateFunctionSequenceCount>); |
67 | 1 | } |
68 | | } // namespace doris |