forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQueryRunnerSettings.cpp
More file actions
59 lines (47 loc) · 2.25 KB
/
Copy pathQueryRunnerSettings.cpp
File metadata and controls
59 lines (47 loc) · 2.25 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <Core/BaseSettings.h>
#include <Core/BaseSettingsFwdMacrosImpl.h>
#include <Parsers/ASTCreateQuery.h>
#include <Parsers/ASTFunction.h>
#include <Storages/QueryRunnerSettings.h>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_SETTING;
}
#define QUERY_RUNNER_SETTINGS(DECLARE, ALIAS) \
DECLARE(String, cluster, "", "Name of the cluster to send the queries to. If empty, the queries are executed locally.", 0) \
DECLARE(String, shard, "1", "1-based index of the cluster's shard to send the queries to, or 'random' to pick a random shard per query, or 'all' to run each query on every shard. Requires the 'cluster' setting.", 0) \
DECLARE(QueryRunnerMode, mode, QueryRunnerMode::ASYNCHRONOUS, "If 'synchronous', INSERT returns after all queries of the inserted batch have finished. If 'asynchronous', INSERT returns as soon as the queries are queued.", 0) \
DECLARE(NonZeroUInt64, threads, 4, "Number of background threads executing the queries.", 0) \
DECLARE(UInt64, max_queue_size, 1000, "Maximum number of queued queries. When the queue is full, newly inserted queries are discarded, and an error is logged.", 0) \
DECLARE_SETTINGS_TRAITS(QueryRunnerSettingsTraits, QUERY_RUNNER_SETTINGS, QUERY_RUNNER_SETTINGS_SUPPORTED_TYPES)
IMPLEMENT_SETTINGS_TRAITS(QueryRunnerSettingsTraits, QUERY_RUNNER_SETTINGS, QueryRunnerSettings, QueryRunnerSetting)
QueryRunnerSettings::QueryRunnerSettings() : impl(std::make_unique<QueryRunnerSettingsImpl>())
{
}
QueryRunnerSettings::QueryRunnerSettings(QueryRunnerSettings && settings) noexcept = default;
QueryRunnerSettings::~QueryRunnerSettings() = default;
QUERY_RUNNER_SETTINGS_SUPPORTED_TYPES(QueryRunnerSettings, IMPLEMENT_SETTING_SUBSCRIPT_OPERATOR)
void QueryRunnerSettings::loadFromQuery(ASTStorage & storage_def)
{
if (storage_def.settings)
{
try
{
impl->applyChanges(storage_def.settings->changes);
}
catch (Exception & e)
{
if (e.code() == ErrorCodes::UNKNOWN_SETTING)
e.addMessage("for storage " + storage_def.engine->name);
throw;
}
}
}
bool QueryRunnerSettings::hasBuiltin(std::string_view name)
{
return QueryRunnerSettingsImpl::hasBuiltin(name);
}
}