2020-07-22 17:13:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST_fwd.h>
|
|
|
|
#include <Interpreters/Aliases.h>
|
|
|
|
#include <Interpreters/DatabaseAndTableWithAlias.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
2020-11-12 23:33:26 +00:00
|
|
|
struct StorageInMemoryMetadata;
|
|
|
|
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
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:
|
|
|
|
static void apply(ASTPtr & query, Aliases & aliases, const NameSet & source_columns_set,
|
|
|
|
const std::vector<TableWithColumnNamesAndTypes> & tables_with_columns,
|
2020-11-12 23:33:26 +00:00
|
|
|
const Context & context, const StorageMetadataPtr & metadata_snapshot,
|
|
|
|
bool & rewrite_subqueries);
|
2020-07-22 17:13:05 +00:00
|
|
|
|
|
|
|
static void optimizeIf(ASTPtr & query, Aliases & aliases, bool if_chain_to_multiif);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|