aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Parsers/ASTSetQuery.h
blob: beed052c79a96797422ce65b0fbce6a0286d5403 (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
40
41
42
43
44
45
#pragma once

#include <Core/Names.h>
#include <Parsers/IAST.h>
#include <Common/SettingsChanges.h>

namespace DB
{

constexpr char QUERY_PARAMETER_NAME_PREFIX[] = "param_";

/** SET query
  */
class ASTSetQuery : public IAST
{
public:
    bool is_standalone = true; /// If false, this AST is a part of another query, such as SELECT.

    /// To support overriding certain settings in a **subquery**, we add a ASTSetQuery with Settings to all subqueries, containing
    /// the list of all settings that affect them (specifically or globally to the whole query).
    /// We use `print_in_format` to avoid printing these nodes when they were left unchanged from the parent copy
    /// See more: https://github.com/ClickHouse/ClickHouse/issues/38895
    bool print_in_format = true;

    SettingsChanges changes;
    /// settings that will be reset to default value
    std::vector<String> default_settings;
    NameToNameMap query_parameters;

    /** Get the text that identifies this element. */
    String getID(char) const override { return "Set"; }

    ASTPtr clone() const override { return std::make_shared<ASTSetQuery>(*this); }

    void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;

    void updateTreeHashImpl(SipHash & hash_state) const override;

    QueryKind getQueryKind() const override { return QueryKind::Set; }

    void appendColumnName(WriteBuffer & ostr) const override;
    void appendColumnNameWithoutAlias(WriteBuffer & ostr) const override { return appendColumnName(ostr); }
};

}