2020-07-22 17:13:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/Aliases.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2020-07-22 17:13:05 +00:00
|
|
|
#include <Interpreters/DatabaseAndTableWithAlias.h>
|
2021-04-24 15:24:32 +00:00
|
|
|
#include <Storages/IStorage_fwd.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
2020-07-22 17:13:05 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-05-21 18:48:19 +00:00
|
|
|
struct TreeRewriterResult;
|
2020-07-22 17:13:05 +00:00
|
|
|
|
|
|
|
/// Part of of Tree Rewriter (SyntaxAnalyzer) that optimizes AST.
|
|
|
|
/// Query should be ready to execute either before either after it. But resulting query could be faster.
|
|
|
|
class TreeOptimizer
|
|
|
|
{
|
|
|
|
public:
|
2021-04-26 14:33:32 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
static void apply(
|
|
|
|
ASTPtr & query,
|
2021-05-21 18:48:19 +00:00
|
|
|
TreeRewriterResult & result,
|
2021-04-10 23:33:54 +00:00
|
|
|
const std::vector<TableWithColumnNamesAndTypes> & tables_with_columns,
|
2021-06-12 00:25:09 +00:00
|
|
|
ContextPtr context);
|
2020-07-22 17:13:05 +00:00
|
|
|
|
|
|
|
static void optimizeIf(ASTPtr & query, Aliases & aliases, bool if_chain_to_multiif);
|
2022-12-02 09:56:23 +00:00
|
|
|
static void optimizeCountConstantAndSumOne(ASTPtr & query, ContextPtr context);
|
2022-11-29 17:22:24 +00:00
|
|
|
static void optimizeGroupByFunctionKeys(ASTSelectQuery * select_query);
|
2020-07-22 17:13:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|