ClickHouse/src/Interpreters/RewriteUniqToCountVisitor.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
753 B
C++
Raw Normal View History

#pragma once
#include <Parsers/IAST.h>
#include <Interpreters/InDepthNodeVisitor.h>
#include "Interpreters/TreeRewriter.h"
namespace DB
{
class ASTFunction;
/// Simple rewrite:
/// 'SELECT uniq(x) FROM (SELECT DISTINCT x ...)' to
/// 'SELECT count() FROM (SELECT DISTINCT x ...)'
///
/// 'SELECT uniq() FROM (SELECT x ... GROUP BY x)' to
/// 'SELECT count() FROM (SELECT x ... GROUP BY x)'
///
/// Note we can rewrite all uniq variants except uniqUpTo.
2023-06-25 06:43:39 +00:00
class RewriteUniqToCountMatcher
{
public:
struct Data {};
static void visit(ASTPtr & ast, Data &);
static bool needChildVisit(const ASTPtr &, const ASTPtr &) { return true; }
};
2023-06-25 06:43:39 +00:00
using RewriteUniqToCountVisitor = InDepthNodeVisitor<RewriteUniqToCountMatcher, true>;
}