aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Analyzer/Passes/CountDistinctPass.h
blob: cac5033c98f9bddd48fac9315f002981e12c59f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include <Analyzer/IQueryTreePass.h>

namespace DB
{

/** Optimize single `countDistinct` into `count` over subquery.
  *
  * Example: SELECT countDistinct(column) FROM table;
  * Result: SELECT count() FROM (SELECT column FROM table GROUP BY column);
  */
class CountDistinctPass final : public IQueryTreePass
{
public:
    String getName() override { return "CountDistinct"; }

    String getDescription() override
    {
        return "Optimize single countDistinct into count over subquery";
    }

    void run(QueryTreeNodePtr query_tree_node, ContextPtr context) override;

};

}