aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Analyzer/Passes/NormalizeCountVariantsPass.h
blob: 78a114f4a85e1470cf4ae5bfd06318969c6a56ba (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
{

/** Remove single literal argument from `count`. Convert `sum` with single `1` literal argument into `count`.
  *
  * Example: SELECT count(1);
  * Result: SELECT count();
  *
  * Example: SELECT sum(1);
  * Result: SELECT count();
  */
class NormalizeCountVariantsPass final : public IQueryTreePass
{
public:
    String getName() override { return "NormalizeCountVariants"; }

    String getDescription() override { return "Optimize count(literal), sum(1) into count()."; }

    void run(QueryTreeNodePtr query_tree_node, ContextPtr context) override;

};

}