-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathTestSQLGeneration
More file actions
239 lines (179 loc) · 7.68 KB
/
TestSQLGeneration
File metadata and controls
239 lines (179 loc) · 7.68 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
--- Begin key_value createTargetTable ---
CREATE TABLE IF NOT EXISTS key_value (
key1 Int64,
key2 Bool,
`key!binary` String,
`array` Nullable(String),
binary Nullable(String),
boolean Nullable(Bool),
field_with_projection Nullable(String),
flow_published_at DateTime64(6, 'UTC'),
integer Nullable(Int64),
integerGt64Bit Nullable(String),
integerWithUserDDL Nullable(DECIMAL(20)),
multiple Nullable(String),
`nonAsciiκόσμε` Nullable(String),
number Nullable(Float64),
numberCastToString Nullable(String),
object Nullable(String),
string Nullable(String),
stringInteger Nullable(String),
stringInteger39Chars Nullable(String),
stringInteger66Chars Nullable(String),
stringNumber Nullable(Float64),
flow_document String,
_is_deleted UInt8 DEFAULT 0
)
ENGINE = ReplacingMergeTree(flow_published_at, _is_deleted)
ORDER BY (key1, key2, `key!binary`)
SETTINGS
allow_experimental_replacing_merge_with_cleanup = 1,
min_age_to_force_merge_seconds = 604800,
min_age_to_force_merge_on_partition_only = 1,
enable_replacing_merge_with_cleanup_for_min_age_to_force_merge = 1;
--- End key_value createTargetTable ---
--- Begin delta_updates createTargetTable ---
CREATE TABLE IF NOT EXISTS delta_updates (
theKey String,
aValue Nullable(Int64),
flow_published_at DateTime64(6, 'UTC')
)
ENGINE = MergeTree
ORDER BY (theKey)
;
--- End delta_updates createTargetTable ---
--- Begin alter table add columns and drop not nulls ---
ALTER TABLE key_value ADD COLUMN IF NOT EXISTS first_new_column Nullable(STRING);
ALTER TABLE key_value ADD COLUMN IF NOT EXISTS second_new_column Nullable(BOOL);
ALTER TABLE key_value MODIFY COLUMN first_required_column Nullable(string);
ALTER TABLE key_value MODIFY COLUMN second_required_column Nullable(bool);
--- End alter table add columns and drop not nulls ---
--- Begin alter table add columns ---
ALTER TABLE key_value ADD COLUMN IF NOT EXISTS first_new_column Nullable(STRING);
ALTER TABLE key_value ADD COLUMN IF NOT EXISTS second_new_column Nullable(BOOL);
--- End alter table add columns ---
--- Begin alter table drop not nulls ---
ALTER TABLE key_value MODIFY COLUMN first_required_column Nullable(string);
ALTER TABLE key_value MODIFY COLUMN second_required_column Nullable(bool);
--- End alter table drop not nulls ---
--- Begin key_value createLoadTable ---
CREATE OR REPLACE TABLE flow_temp_load_0_key_value (
key1 Int64,
key2 Bool,
`key!binary` String
)
ENGINE = MergeTree
ORDER BY (key1, key2, `key!binary`);
--- End key_value createLoadTable ---
--- Begin delta_updates createLoadTable ---
CREATE OR REPLACE TABLE flow_temp_load_0_delta_updates (
theKey String
)
ENGINE = MergeTree
ORDER BY (theKey);
--- End delta_updates createLoadTable ---
--- Begin key_value queryLoadTable ---
SELECT 0::Int32, r.flow_document
FROM key_value AS r FINAL
JOIN flow_temp_load_0_key_value AS l
ON l.key1 = r.key1
AND l.key2 = r.key2
AND l.`key!binary` = r.`key!binary`
--- End key_value queryLoadTable ---
--- Begin delta_updates queryLoadTable ---
--- End delta_updates queryLoadTable ---
--- Begin key_value queryLoadTableNoFlowDocument ---
SELECT 0::Int32,
concat('{',
'"key1":', ifNull(toJSONString(r.key1), 'null'), ',',
'"key2":', ifNull(toJSONString(r.key2), 'null'), ',',
'"key!binary":', ifNull(toJSONString(r.`key!binary`), 'null'), ',',
'"array":', ifNull(r.`array`, 'null'), ',',
'"binary":', ifNull(toJSONString(r.binary), 'null'), ',',
'"boolean":', ifNull(toJSONString(r.boolean), 'null'), ',',
'"field_with_projection":', ifNull(toJSONString(r.field_with_projection), 'null'), ',',
'"integer":', ifNull(toJSONString(r.integer), 'null'), ',',
'"integerGt64Bit":', ifNull(toJSONString(r.integerGt64Bit), 'null'), ',',
'"integerWithUserDDL":', ifNull(toJSONString(r.integerWithUserDDL), 'null'), ',',
'"multiple":', ifNull(r.multiple, 'null'), ',',
'"nonAsciiκόσμε":', ifNull(toJSONString(r.`nonAsciiκόσμε`), 'null'), ',',
'"number":', ifNull(toJSONString(r.number), 'null'), ',',
'"numberCastToString":', ifNull(toJSONString(toString(r.numberCastToString)), 'null'), ',',
'"object":', ifNull(r.object, 'null'), ',',
'"string":', ifNull(toJSONString(r.string), 'null'), ',',
'"stringInteger":', ifNull(toJSONString(r.stringInteger), 'null'), ',',
'"stringInteger39Chars":', ifNull(toJSONString(r.stringInteger39Chars), 'null'), ',',
'"stringInteger66Chars":', ifNull(toJSONString(r.stringInteger66Chars), 'null'), ',',
'"stringNumber":', ifNull(toJSONString(toString(r.stringNumber)), 'null')
, '}') AS flow_document
FROM key_value AS r FINAL
JOIN flow_temp_load_0_key_value AS l
ON l.key1 = r.key1
AND l.key2 = r.key2
AND l.`key!binary` = r.`key!binary`
--- End key_value queryLoadTableNoFlowDocument ---
--- Begin delta_updates queryLoadTableNoFlowDocument ---
SELECT * FROM (SELECT -1::Int32, ''::String LIMIT 0) as nodoc
--- End delta_updates queryLoadTableNoFlowDocument ---
--- Begin key_value insertLoadTable ---
INSERT INTO flow_temp_load_0_key_value (key1, key2, `key!binary`)
--- End key_value insertLoadTable ---
--- Begin delta_updates insertLoadTable ---
INSERT INTO flow_temp_load_0_delta_updates (theKey)
--- End delta_updates insertLoadTable ---
--- Begin key_value dropLoadTable ---
DROP TABLE IF EXISTS flow_temp_load_0_key_value;
--- End key_value dropLoadTable ---
--- Begin delta_updates dropLoadTable ---
DROP TABLE IF EXISTS flow_temp_load_0_delta_updates;
--- End delta_updates dropLoadTable ---
--- Begin key_value createStoreTable ---
CREATE OR REPLACE TABLE flow_temp_store_0_key_value
AS key_value;
--- End key_value createStoreTable ---
--- Begin delta_updates createStoreTable ---
CREATE OR REPLACE TABLE flow_temp_store_0_delta_updates
AS delta_updates;
--- End delta_updates createStoreTable ---
--- Begin key_value insertStoreTable ---
INSERT INTO flow_temp_store_0_key_value (key1, key2, `key!binary`, `array`, binary, boolean, field_with_projection, flow_published_at, integer, integerGt64Bit, integerWithUserDDL, multiple, `nonAsciiκόσμε`, number, numberCastToString, object, string, stringInteger, stringInteger39Chars, stringInteger66Chars, stringNumber, flow_document, _is_deleted)
--- End key_value insertStoreTable ---
--- Begin delta_updates insertStoreTable ---
INSERT INTO flow_temp_store_0_delta_updates (theKey, aValue, flow_published_at)
--- End delta_updates insertStoreTable ---
--- Begin key_value queryStoreParts ---
SELECT DISTINCT partition_id FROM system.parts
WHERE table = 'flow_temp_store_0_key_value'
AND database = ? AND active;
--- End key_value queryStoreParts ---
--- Begin delta_updates queryStoreParts ---
SELECT DISTINCT partition_id FROM system.parts
WHERE table = 'flow_temp_store_0_delta_updates'
AND database = ? AND active;
--- End delta_updates queryStoreParts ---
--- Begin key_value moveStorePartition ---
ALTER TABLE flow_temp_store_0_key_value
MOVE PARTITION ID ?
TO TABLE key_value;
--- End key_value moveStorePartition ---
--- Begin delta_updates moveStorePartition ---
ALTER TABLE flow_temp_store_0_delta_updates
MOVE PARTITION ID ?
TO TABLE delta_updates;
--- End delta_updates moveStorePartition ---
--- Begin key_value existsStoreTable ---
SELECT count() FROM system.tables
WHERE database = currentDatabase()
AND name = 'flow_temp_store_0_key_value';
--- End key_value existsStoreTable ---
--- Begin delta_updates existsStoreTable ---
SELECT count() FROM system.tables
WHERE database = currentDatabase()
AND name = 'flow_temp_store_0_delta_updates';
--- End delta_updates existsStoreTable ---
--- Begin key_value dropStoreTable ---
DROP TABLE IF EXISTS flow_temp_store_0_key_value;
--- End key_value dropStoreTable ---
--- Begin delta_updates dropStoreTable ---
DROP TABLE IF EXISTS flow_temp_store_0_delta_updates;
--- End delta_updates dropStoreTable ---