be/src/exprs/aggregate/aggregate_function_reader_replace.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_reader.h" |
19 | | #include "exprs/aggregate/aggregate_function_reader_first_last.h" |
20 | | #include "exprs/aggregate/aggregate_function_simple_factory.h" |
21 | | |
22 | | namespace doris { |
23 | | #include "common/compile_check_begin.h" |
24 | | |
25 | | // only replace function in load/reader do different agg operation. |
26 | | // because Doris can ensure that the data is globally ordered in reader, but cannot in load |
27 | | // 1. reader, get the first value of input data. |
28 | | // 2. load, get the last value of input data. |
29 | 9 | void register_aggregate_function_replace_reader_load(AggregateFunctionSimpleFactory& factory) { |
30 | 9 | auto register_function = [&](const std::string& name, const std::string& suffix, |
31 | 72 | const AggregateFunctionCreator& creator, bool nullable) { |
32 | 72 | factory.register_function(name + suffix, creator, nullable); |
33 | 72 | }; |
34 | | |
35 | 9 | register_function("replace", AGG_READER_SUFFIX, create_aggregate_function_first<true>, false); |
36 | 9 | register_function("replace", AGG_READER_SUFFIX, create_aggregate_function_first<true>, true); |
37 | 9 | register_function("replace", AGG_LOAD_SUFFIX, create_aggregate_function_last<false>, false); |
38 | 9 | register_function("replace", AGG_LOAD_SUFFIX, create_aggregate_function_last<false>, true); |
39 | | |
40 | 9 | register_function("replace_if_not_null", AGG_READER_SUFFIX, |
41 | 9 | create_aggregate_function_first_non_null_value<true>, false); |
42 | 9 | register_function("replace_if_not_null", AGG_READER_SUFFIX, |
43 | 9 | create_aggregate_function_first_non_null_value<true>, true); |
44 | 9 | register_function("replace_if_not_null", AGG_LOAD_SUFFIX, |
45 | 9 | create_aggregate_function_last_non_null_value<false>, false); |
46 | 9 | register_function("replace_if_not_null", AGG_LOAD_SUFFIX, |
47 | 9 | create_aggregate_function_last_non_null_value<false>, true); |
48 | 9 | } |
49 | | |
50 | | } // namespace doris |