2020-06-15 12:03:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
2021-09-11 22:15:37 +00:00
|
|
|
|
2020-06-15 12:03:01 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-09-11 22:24:02 +00:00
|
|
|
class ASTSelectQuery;
|
2020-06-15 12:03:01 +00:00
|
|
|
|
|
|
|
/// Erases unnecessary ORDER BY from subquery
|
|
|
|
class DuplicateOrderByFromSubqueriesData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using TypeToVisit = ASTSelectQuery;
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
|
2021-09-11 22:24:02 +00:00
|
|
|
void visit(ASTSelectQuery & select_query, ASTPtr &);
|
2020-06-15 12:03:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using DuplicateOrderByFromSubqueriesMatcher = OneTypeMatcher<DuplicateOrderByFromSubqueriesData>;
|
|
|
|
using DuplicateOrderByFromSubqueriesVisitor = InDepthNodeVisitor<DuplicateOrderByFromSubqueriesMatcher, true>;
|
|
|
|
|
|
|
|
|
|
|
|
/// Finds SELECT that can be optimized
|
|
|
|
class DuplicateOrderByData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using TypeToVisit = ASTSelectQuery;
|
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
ContextPtr context;
|
2020-06-15 12:03:01 +00:00
|
|
|
|
2021-09-11 22:24:02 +00:00
|
|
|
void visit(ASTSelectQuery & select_query, ASTPtr &);
|
2020-06-15 12:03:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using DuplicateOrderByMatcher = OneTypeMatcher<DuplicateOrderByData>;
|
|
|
|
using DuplicateOrderByVisitor = InDepthNodeVisitor<DuplicateOrderByMatcher, true>;
|
|
|
|
|
|
|
|
}
|