2019-02-01 16:36:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
2020-03-18 21:38:27 +00:00
|
|
|
#include <Interpreters/Aliases.h>
|
2019-02-01 16:36:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ASTSelectQuery;
|
2020-03-08 11:07:05 +00:00
|
|
|
struct TableWithColumnNamesAndTypes;
|
2019-02-01 16:36:40 +00:00
|
|
|
|
|
|
|
/// AST transformer. It replaces cross joins with equivalented inner join if possible.
|
|
|
|
class CrossToInnerJoinMatcher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Data
|
|
|
|
{
|
2020-03-08 11:07:05 +00:00
|
|
|
const std::vector<TableWithColumnNamesAndTypes> & tables_with_columns;
|
2020-03-18 21:38:27 +00:00
|
|
|
const Aliases & aliases;
|
2020-03-08 11:07:05 +00:00
|
|
|
const String current_database;
|
2019-02-01 16:36:40 +00:00
|
|
|
bool done = false;
|
2021-02-19 12:14:24 +00:00
|
|
|
bool cross_to_inner_join_rewrite = true;
|
2019-02-01 16:36:40 +00:00
|
|
|
};
|
|
|
|
|
2020-03-08 11:07:05 +00:00
|
|
|
static bool needChildVisit(ASTPtr &, const ASTPtr &);
|
2019-02-22 13:33:56 +00:00
|
|
|
static void visit(ASTPtr & ast, Data & data);
|
2019-02-01 16:36:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void visit(ASTSelectQuery & select, ASTPtr & ast, Data & data);
|
|
|
|
};
|
|
|
|
|
|
|
|
using CrossToInnerJoinVisitor = InDepthNodeVisitor<CrossToInnerJoinMatcher, true>;
|
|
|
|
|
|
|
|
}
|