Coverage Report

Created: 2026-10-29 18:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/exprs/aggregate/aggregate_function_topk.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_topk.h"
19
20
#include "core/data_type/define_primitive_type.h"
21
#include "exprs/aggregate/aggregate_function_simple_factory.h"
22
#include "exprs/aggregate/factory_helpers.h"
23
#include "exprs/aggregate/helpers.h"
24
25
namespace doris {
26
27
namespace {
28
29
template <PrimitiveType T>
30
using TopKMin = AggregateFunctionTopK<T, true>;
31
32
template <PrimitiveType T>
33
using TopKMax = AggregateFunctionTopK<T, false>;
34
35
/// Constructs the aggregate directly instead of using creator_without_type, which would wrap it in
36
/// a nullable-argument adapter. That adapter drops every row where any argument is NULL *before*
37
/// add() runs, so an evaluated-but-NULL count would never be validated and the group would
38
/// silently return an empty state. The function reads k itself for every row, including rows
39
/// whose x is NULL.
40
template <template <PrimitiveType> class FunctionTemplate, PrimitiveType... AllowedTypes>
41
struct TopKCountCreator {
42
39
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
39
        AggregateFunctionPtr result;
44
936
        (([&] {
45
936
             if (type == AllowedTypes) {
46
39
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
39
             }
48
936
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE22_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE21_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE20_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE19_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
16
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
16
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE18_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE17_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE16_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE15_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE14_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE13_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE12_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE11_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE10_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE9_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
10
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
10
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE8_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE7_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE6_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE5_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE4_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE3_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE2_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE1_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE0_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE_clEv
Line
Count
Source
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
26
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE22_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE21_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE20_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE19_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
12
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
12
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE18_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE17_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE16_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE15_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE14_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE13_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE12_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE11_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE10_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE9_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
1
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
1
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE8_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE7_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE6_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE5_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE4_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE3_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE2_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE1_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE0_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
aggregate_function_topk.cpp:_ZZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EEENKUlvE_clEv
Line
Count
Source
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
13
         }()),
49
39
         ...);
50
39
        return result;
51
39
    }
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMinEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
42
26
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
26
        AggregateFunctionPtr result;
44
26
        (([&] {
45
26
             if (type == AllowedTypes) {
46
26
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
26
             }
48
26
         }()),
49
26
         ...);
50
26
        return result;
51
26
    }
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_116TopKCountCreatorINS0_7TopKMaxEJLNS_13PrimitiveTypeE2ELS3_3ELS3_4ELS3_5ELS3_6ELS3_7ELS3_8ELS3_9ELS3_28ELS3_29ELS3_20ELS3_30ELS3_35ELS3_10ELS3_11ELS3_12ELS3_25ELS3_26ELS3_27ELS3_43ELS3_42ELS3_36ELS3_37ELS3_44EEE6createES3_RKSt6vectorISt10shared_ptrIKNS_9IDataTypeEESaIS9_EE
Line
Count
Source
42
13
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
13
        AggregateFunctionPtr result;
44
13
        (([&] {
45
13
             if (type == AllowedTypes) {
46
13
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
13
             }
48
13
         }()),
49
13
         ...);
50
13
        return result;
51
13
    }
52
};
53
54
// Keep in sync with TopKFunction.isSupportedValueType on the FE side.
55
template <template <PrimitiveType> class FunctionTemplate>
56
using TopKCount = TopKCountCreator<FunctionTemplate, TYPE_BOOLEAN, TYPE_TINYINT, TYPE_SMALLINT,
57
                                   TYPE_INT, TYPE_BIGINT, TYPE_LARGEINT, TYPE_FLOAT, TYPE_DOUBLE,
58
                                   TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMALV2, TYPE_DECIMAL128I,
59
                                   TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATE, TYPE_DATETIME,
60
                                   TYPE_DATEV2, TYPE_DATETIMEV2, TYPE_TIMEV2, TYPE_TIMESTAMP_NS,
61
                                   TYPE_TIMESTAMPTZ, TYPE_IPV4, TYPE_IPV6, TYPE_UUID>;
62
63
template <template <PrimitiveType> class FunctionTemplate>
64
AggregateFunctionPtr create_topk(const std::string& name, const DataTypes& argument_types,
65
39
                                 const bool result_is_nullable, const AggregateFunctionAttr& attr) {
66
    // The function always returns a non-nullable array, the same contract the generic nullable
67
    // adapter enforced.
68
39
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
39
    auto type = argument_types[0]->get_primitive_type();
72
39
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
11
        type = TYPE_VARCHAR;
74
11
    }
75
39
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
39
}
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_111create_topkINS0_7TopKMinEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS3_IKNS_9IDataTypeEESaISH_EEbRKNS_21AggregateFunctionAttrE
Line
Count
Source
65
26
                                 const bool result_is_nullable, const AggregateFunctionAttr& attr) {
66
    // The function always returns a non-nullable array, the same contract the generic nullable
67
    // adapter enforced.
68
26
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
26
    auto type = argument_types[0]->get_primitive_type();
72
26
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
10
        type = TYPE_VARCHAR;
74
10
    }
75
26
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
26
}
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_111create_topkINS0_7TopKMaxEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS3_IKNS_9IDataTypeEESaISH_EEbRKNS_21AggregateFunctionAttrE
Line
Count
Source
65
13
                                 const bool result_is_nullable, const AggregateFunctionAttr& attr) {
66
    // The function always returns a non-nullable array, the same contract the generic nullable
67
    // adapter enforced.
68
13
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
13
    auto type = argument_types[0]->get_primitive_type();
72
13
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
1
        type = TYPE_VARCHAR;
74
1
    }
75
13
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
13
}
77
78
AggregateFunctionPtr create_aggregate_function_min_topk(const std::string& name,
79
                                                        const DataTypes& argument_types,
80
                                                        const DataTypePtr& result_type,
81
                                                        const bool result_is_nullable,
82
26
                                                        const AggregateFunctionAttr& attr) {
83
26
    assert_arity_range(name, argument_types, 2, 2);
84
26
    return create_topk<TopKMin>(name, argument_types, result_is_nullable, attr);
85
26
}
86
87
AggregateFunctionPtr create_aggregate_function_max_topk(const std::string& name,
88
                                                        const DataTypes& argument_types,
89
                                                        const DataTypePtr& result_type,
90
                                                        const bool result_is_nullable,
91
13
                                                        const AggregateFunctionAttr& attr) {
92
13
    assert_arity_range(name, argument_types, 2, 2);
93
13
    return create_topk<TopKMax>(name, argument_types, result_is_nullable, attr);
94
13
}
95
96
} // namespace
97
98
19
void register_aggregate_function_topk(AggregateFunctionSimpleFactory& factory) {
99
19
    factory.register_function_both("min_topk", create_aggregate_function_min_topk);
100
19
    factory.register_function_both("max_topk", create_aggregate_function_max_topk);
101
19
}
102
103
} // namespace doris