Coverage Report

Created: 2026-10-27 06:29

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
85
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
85
        AggregateFunctionPtr result;
44
2.04k
        (([&] {
45
2.04k
             if (type == AllowedTypes) {
46
85
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
85
             }
48
2.04k
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
1
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
1
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
42
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
42
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
51
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
26
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
26
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
2
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
2
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
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
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
0
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
0
             }
48
34
         }()),
49
85
         ...);
50
85
        return result;
51
85
    }
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
51
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
51
        AggregateFunctionPtr result;
44
51
        (([&] {
45
51
             if (type == AllowedTypes) {
46
51
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
51
             }
48
51
         }()),
49
51
         ...);
50
51
        return result;
51
51
    }
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
34
    static AggregateFunctionPtr create(PrimitiveType type, const DataTypes& argument_types) {
43
34
        AggregateFunctionPtr result;
44
34
        (([&] {
45
34
             if (type == AllowedTypes) {
46
34
                 result = std::make_shared<FunctionTemplate<AllowedTypes>>(argument_types);
47
34
             }
48
34
         }()),
49
34
         ...);
50
34
        return result;
51
34
    }
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
85
                                 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
85
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
85
    auto type = argument_types[0]->get_primitive_type();
72
85
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
0
        type = TYPE_VARCHAR;
74
0
    }
75
85
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
85
}
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_111create_topkINS0_7TopKMinEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS3_IKNS_9IDataTypeEESaISH_EEbRKNS_21AggregateFunctionAttrE
Line
Count
Source
65
51
                                 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
51
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
51
    auto type = argument_types[0]->get_primitive_type();
72
51
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
0
        type = TYPE_VARCHAR;
74
0
    }
75
51
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
51
}
aggregate_function_topk.cpp:_ZN5doris12_GLOBAL__N_111create_topkINS0_7TopKMaxEEESt10shared_ptrINS_18IAggregateFunctionEERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIS3_IKNS_9IDataTypeEESaISH_EEbRKNS_21AggregateFunctionAttrE
Line
Count
Source
65
34
                                 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
34
    if (!attr.is_foreach && result_is_nullable) {
69
0
        throw Exception(ErrorCode::INTERNAL_ERROR, "{} must return a non-nullable array", name);
70
0
    }
71
34
    auto type = argument_types[0]->get_primitive_type();
72
34
    if (type == TYPE_CHAR || type == TYPE_STRING || type == TYPE_JSONB) {
73
0
        type = TYPE_VARCHAR;
74
0
    }
75
34
    return TopKCount<FunctionTemplate>::create(type, argument_types);
76
34
}
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
51
                                                        const AggregateFunctionAttr& attr) {
83
51
    assert_arity_range(name, argument_types, 2, 2);
84
51
    return create_topk<TopKMin>(name, argument_types, result_is_nullable, attr);
85
51
}
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
34
                                                        const AggregateFunctionAttr& attr) {
92
34
    assert_arity_range(name, argument_types, 2, 2);
93
34
    return create_topk<TopKMax>(name, argument_types, result_is_nullable, attr);
94
34
}
95
96
} // namespace
97
98
16
void register_aggregate_function_topk(AggregateFunctionSimpleFactory& factory) {
99
16
    factory.register_function_both("min_topk", create_aggregate_function_min_topk);
100
16
    factory.register_function_both("max_topk", create_aggregate_function_max_topk);
101
16
}
102
103
} // namespace doris