aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/QueryWithOutputSettingsPushDownVisitor.h
blob: fde8a07b55519e8bd7be4e78e63ab073e4e45006 (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
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include <Parsers/IAST.h>
#include <Interpreters/InDepthNodeVisitor.h>

namespace DB
{

class ASTSelectQuery;
struct SettingChange;
class SettingsChanges;

/// Pushdown SETTINGS clause that goes after FORMAT to the SELECT query:
/// (since settings after FORMAT parsed separately not in the ParserSelectQuery but in ParserQueryWithOutput)
///
///     SELECT 1                             FORMAT Null SETTINGS max_block_size = 1 ->
///     SELECT 1 SETTINGS max_block_size = 1 FORMAT Null SETTINGS max_block_size = 1
///
/// Otherwise settings after FORMAT will not be applied.
class QueryWithOutputSettingsPushDownMatcher
{
public:
    using Visitor = InDepthNodeVisitor<QueryWithOutputSettingsPushDownMatcher, true>;

    struct Data
    {
        const ASTPtr & settings_ast;
    };

    static bool needChildVisit(ASTPtr & node, const ASTPtr & child);
    static void visit(ASTPtr & ast, Data & data);

private:
    static void visit(ASTSelectQuery &, ASTPtr &, Data &);
};

using QueryWithOutputSettingsPushDownVisitor = QueryWithOutputSettingsPushDownMatcher::Visitor;

}