aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/InsertQuerySettingsPushDownVisitor.h
blob: d1f161fc89b411ae3fcb0fa9e9d5ee5a8fb0af2a (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
#pragma once

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

namespace DB
{

class ASTSelectQuery;
struct SettingChange;
class SettingsChanges;

/// Pushdown SETTINGS clause to the INSERT from the SELECT query:
/// (since SETTINGS after SELECT will be parsed by the SELECT parser.)
///
/// NOTE: INSERT ... SELECT ... FORMAT Null SETTINGS max_insert_threads=10 works even without push down,
/// since ParserInsertQuery does not use ParserQueryWithOutput.
class InsertQuerySettingsPushDownMatcher
{
public:
    using Visitor = InDepthNodeVisitor<InsertQuerySettingsPushDownMatcher, true>;

    struct Data
    {
        ASTPtr & insert_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 InsertQuerySettingsPushDownVisitor = InsertQuerySettingsPushDownMatcher::Visitor;

}