aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/GatherFunctionQuantileVisitor.h
blob: 74388e7161a39bf33a24aaf35280aec524822828 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <Interpreters/InDepthNodeVisitor.h>
#include <Parsers/IAST_fwd.h>

namespace DB
{

class ASTFunction;

/// Gather all the `quantile*` functions
class GatherFunctionQuantileData
{
public:
    struct FuseQuantileAggregatesData
    {
        std::unordered_map<String, std::vector<ASTPtr *>> arg_map_function;

        void addFuncNode(ASTPtr & ast);
    };

    using TypeToVisit = ASTFunction;

    std::unordered_map<String, FuseQuantileAggregatesData> fuse_quantile;

    void visit(ASTFunction & function, ASTPtr & ast);

    static String toFusedNameOrSelf(const String & func_name);

    static String getFusedName(const String & func_name);

    static bool needChild(const ASTPtr & node, const ASTPtr &);
};

using GatherFunctionQuantileVisitor = InDepthNodeVisitor<OneTypeMatcher<GatherFunctionQuantileData, GatherFunctionQuantileData::needChild>, true>;

}