1#pragma once
2
3#include <Core/QueryProcessingStage.h>
4
5namespace DB
6{
7
8/**
9 * to_stage
10 * - the stage to which the query is to be executed. By default - till to the end.
11 * You can perform till the intermediate aggregation state, which are combined from different servers for distributed query processing.
12 *
13 * subquery_depth
14 * - to control the limit on the depth of nesting of subqueries. For subqueries, a value that is incremented by one is passed;
15 * for INSERT SELECT, a value 1 is passed instead of 0.
16 *
17 * only_analyze
18 * - the object was created only for query analysis.
19 *
20 * is_subquery
21 * - there could be some specific for subqueries. Ex. there's no need to pass duplicated columns in results, cause of indirect results.
22 */
23struct SelectQueryOptions
24{
25 QueryProcessingStage::Enum to_stage;
26 size_t subquery_depth;
27 bool only_analyze = false;
28 bool modify_inplace = false;
29 bool remove_duplicates = false;
30 bool ignore_quota = false;
31 bool ignore_limits = false;
32
33 SelectQueryOptions(QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, size_t depth = 0)
34 : to_stage(stage), subquery_depth(depth)
35 {
36 }
37
38 SelectQueryOptions copy() const { return *this; }
39
40 SelectQueryOptions subquery() const
41 {
42 SelectQueryOptions out = *this;
43 out.to_stage = QueryProcessingStage::Complete;
44 ++out.subquery_depth;
45 return out;
46 }
47
48 SelectQueryOptions & analyze(bool value = true)
49 {
50 only_analyze = value;
51 return *this;
52 }
53
54 SelectQueryOptions & modify(bool value = true)
55 {
56 modify_inplace = value;
57 return *this;
58 }
59
60 SelectQueryOptions & noModify() { return modify(false); }
61
62 SelectQueryOptions & removeDuplicates(bool value = true)
63 {
64 remove_duplicates = value;
65 return *this;
66 }
67
68 SelectQueryOptions & noSubquery()
69 {
70 subquery_depth = 0;
71 return *this;
72 }
73
74 SelectQueryOptions & ignoreLimits(bool value = true)
75 {
76 ignore_limits = value;
77 return *this;
78 }
79};
80
81}
82