2021-07-21 06:43:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-11-26 17:21:54 +00:00
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
|
|
#include <Parsers/IAST_fwd.h>
|
2021-07-21 06:43:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-11-26 17:21:54 +00:00
|
|
|
class ASTFunction;
|
|
|
|
|
2021-08-25 08:24:53 +00:00
|
|
|
/// Gather all the `quantile*` functions
|
2021-07-21 06:43:40 +00:00
|
|
|
class GatherFunctionQuantileData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct FuseQuantileAggregatesData
|
|
|
|
{
|
2021-08-25 08:24:53 +00:00
|
|
|
std::unordered_map<String, std::vector<ASTPtr *>> arg_map_function;
|
2021-07-21 06:43:40 +00:00
|
|
|
|
2021-09-15 12:15:42 +00:00
|
|
|
void addFuncNode(ASTPtr & ast);
|
2021-07-21 06:43:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using TypeToVisit = ASTFunction;
|
2021-09-15 12:15:42 +00:00
|
|
|
|
2021-07-21 06:43:40 +00:00
|
|
|
std::unordered_map<String, FuseQuantileAggregatesData> fuse_quantile;
|
2021-08-25 08:24:53 +00:00
|
|
|
|
2021-09-15 12:15:42 +00:00
|
|
|
void visit(ASTFunction & function, ASTPtr & ast);
|
|
|
|
|
2022-07-21 15:08:42 +00:00
|
|
|
static String toFusedNameOrSelf(const String & func_name);
|
|
|
|
|
2021-09-15 12:15:42 +00:00
|
|
|
static String getFusedName(const String & func_name);
|
2021-07-21 06:43:40 +00:00
|
|
|
|
2021-09-17 11:30:45 +00:00
|
|
|
static bool needChild(const ASTPtr & node, const ASTPtr &);
|
2021-07-21 06:43:40 +00:00
|
|
|
};
|
|
|
|
|
2021-09-17 11:30:45 +00:00
|
|
|
using GatherFunctionQuantileVisitor = InDepthNodeVisitor<OneTypeMatcher<GatherFunctionQuantileData, GatherFunctionQuantileData::needChild>, true>;
|
2021-07-21 06:43:40 +00:00
|
|
|
|
|
|
|
}
|