-
Notifications
You must be signed in to change notification settings - Fork 1
/
migration.cql
409 lines (366 loc) · 8.1 KB
/
migration.cql
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
CREATE KEYSPACE cassarrow
WITH REPLICATION = {
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
CREATE TABLE cassarrow.time_series
(
event_date date,
instrument_id int,
event_timestamp timestamp,
value double,
PRIMARY KEY (event_date, instrument_id, event_timestamp)
);
CREATE TABLE cassarrow.simple_primitives
(
partition_key varchar,
secondary_key varchar,
ascii_col ascii,
bigint_col bigint,
blob_col blob,
boolean_col boolean,
date_col date,
double_col double,
duration_col duration,
float_col float,
int_col int,
smallint_col smallint,
text_col text,
time_col time,
timestamp_col timestamp,
tinyint_col tinyint,
varchar_col varchar,
PRIMARY KEY (partition_key, secondary_key)
);
INSERT INTO cassarrow.simple_primitives JSON '{
"partition_key": "test",
"secondary_key": "empty"
}';
INSERT INTO cassarrow.simple_primitives JSON '{
"partition_key": "test",
"secondary_key": "valid",
"ascii_col": "hello world",
"bigint_col": 1234567890,
"blob_col": "0x0000000000000003",
"boolean_col": false,
"date_col": "2021-12-14",
"double_col": 3.14,
"duration_col": "P4Y6M3DT12H30M5S",
"float_col": 2.718,
"int_col": 1234,
"smallint_col": 280,
"text_col": "ABC",
"time_col": "08:10:22.123",
"timestamp_col": "2017-05-05 21:01:29.123",
"tinyint_col": 8,
"varchar_col": "abc"
}';
CREATE TABLE cassarrow.primitives
(
partition_key varchar,
secondary_key varchar,
ascii_col ascii,
bigint_col bigint,
blob_col blob,
boolean_col boolean,
-- counter_col counter, -- Cannot mix counter and non counter columns in the same table
date_col date,
decimal_col decimal,
double_col double,
duration_col duration,
float_col float,
inet_col inet,
int_col int,
smallint_col smallint,
text_col text,
time_col time,
timestamp_col timestamp,
timeuuid_col timeuuid,
tinyint_col tinyint,
uuid_col uuid,
varchar_col varchar,
varint_col varint,
PRIMARY KEY (partition_key, secondary_key)
);
INSERT INTO cassarrow.primitives JSON '{
"partition_key": "test",
"secondary_key": "empty",
"ascii_col": null,
"bigint_col": null,
"blob_col": null,
"boolean_col": null,
"date_col": null,
"decimal_col": null,
"double_col": null,
"duration_col": null,
"float_col": null,
"inet_col": null,
"int_col": null,
"smallint_col": null,
"text_col": null,
"time_col": null,
"timestamp_col": null,
"timeuuid_col": null,
"tinyint_col": null,
"uuid_col": null,
"varchar_col": null,
"varint_col": null
}';
INSERT INTO cassarrow.primitives JSON '
{
"partition_key": "test",
"secondary_key": "valid",
"ascii_col": "hello world",
"bigint_col": 1234567890,
"blob_col": "0x0000000000000003",
"boolean_col": false,
"date_col": "2021-12-14",
"decimal_col": 123.456,
"double_col": 3.14,
"duration_col": "P4Y6M3DT12H30M5S",
"float_col": 2.718,
"inet_col": "fe80::1ff:fe23:4567:890a",
"int_col": 1234,
"smallint_col": 280,
"text_col": "ABC",
"time_col": "08:10:22.123",
"timestamp_col": "2017-05-05 00:00:00.000",
"timeuuid_col": "50554d6e-29bb-11e5-b345-feff819cdc9f",
"tinyint_col": 8,
"uuid_col": "50554d6e-29bb-11e5-b345-feff819cdc9f",
"varchar_col": "abc",
"varint_col": 1234567890123
}
';
INSERT INTO cassarrow.simple_primitives JSON '{
"partition_key": "test",
"secondary_key": "duration_1",
"duration_col": "P4Y6M3DT12H30M5S"
}';
INSERT INTO cassarrow.simple_primitives JSON '{
"partition_key": "test",
"secondary_key": "duration_2",
"duration_col": "2mo10d12h"
}';
INSERT INTO cassarrow.simple_primitives JSON '{
"partition_key": "test",
"secondary_key": "duration_3",
"duration_col": "P0004-06-03T12:30:05"
}';
CREATE TABLE cassarrow.simple_list
(
partition_key varchar,
secondary_key varchar,
ascii_col list<ascii>,
bigint_col list<bigint>,
blob_col list<blob>,
boolean_col list<boolean>,
date_col list<date>,
double_col list<double>,
duration_col list<duration>,
float_col list<float>,
int_col list<int>,
smallint_col list<smallint>,
text_col list<text>,
time_col list<time>,
timestamp_col list<timestamp>,
tinyint_col list<tinyint>,
varchar_col list<varchar>,
PRIMARY KEY (partition_key, secondary_key)
);
INSERT INTO cassarrow.simple_list JSON '
{
"partition_key": "test",
"secondary_key": "empty"
}';
INSERT INTO cassarrow.simple_list JSON '
{
"partition_key": "test",
"secondary_key": "valid",
"ascii_col": [
"hello world"
],
"bigint_col": [
1234567890
],
"blob_col": [
"0x0000000000000003"
],
"boolean_col": [
false
],
"date_col": [
"2021-12-14"
],
"double_col": [
3.14
],
"duration_col": [
"P4Y6M3DT12H30M5S"
],
"float_col": [
2.718
],
"int_col": [
1234
],
"smallint_col": [
280
],
"text_col": [
"ABC"
],
"time_col": [
"08:10:22.123"
],
"timestamp_col": [
"2017-05-05 00:00:00.000"
],
"tinyint_col": [
8
],
"varchar_col": [
"abc"
]
}
';
CREATE TABLE cassarrow.simple_set
(
partition_key varchar,
secondary_key varchar,
ascii_col set<ascii>,
bigint_col set<bigint>,
blob_col set<blob>,
boolean_col set<boolean>,
date_col set<date>,
double_col set<double>,
float_col set<float>,
int_col set<int>,
smallint_col set<smallint>,
text_col set<text>,
time_col set<time>,
timestamp_col set<timestamp>,
tinyint_col set<tinyint>,
varchar_col set<varchar>,
PRIMARY KEY (partition_key, secondary_key)
);
INSERT INTO cassarrow.simple_set JSON '
{
"partition_key": "test",
"secondary_key": "valid",
"ascii_col": [
"hello world"
],
"bigint_col": [
1234567890
],
"blob_col": [
"0x0000000000000003"
],
"boolean_col": [
false
],
"date_col": [
"2021-12-14"
],
"double_col": [
3.14
],
"float_col": [
2.718
],
"int_col": [
1234
],
"smallint_col": [
280
],
"text_col": [
"ABC"
],
"time_col": [
"08:10:22.123"
],
"timestamp_col": [
"2017-05-05 00:00:00.000"
],
"tinyint_col": [
8
],
"varchar_col": [
"abc"
]
}
';
INSERT INTO cassarrow.simple_set JSON '{
"partition_key": "test",
"secondary_key": "empty"
}';
CREATE TYPE cassarrow.basic_info (
birthday timestamp,
nationality text,
weight text,
height text,
phones frozen<list<text>>,
);
CREATE TABLE cassarrow.cyclist_stats
(
id uuid PRIMARY KEY,
lastname text,
basics FROZEN<basic_info>
);
INSERT INTO cassarrow.cyclist_stats JSON '
{
"id": "50554d6e-29bb-11e5-b345-feff819cdc9f",
"lastname": "Smith",
"basics": {
"birthday": "2017-05-05 00:00:00.000",
"nationality": "British",
"weight": "70kg",
"height": "173cm",
"phones": [
"00447123123123",
"00447456456456"
]
}
}
';
INSERT INTO cassarrow.cyclist_stats JSON '
{
"id": "50554d6e-29bb-11e5-b345-feff819cdc9a",
"lastname": "Missing",
"basics": null
}
';
CREATE TABLE cassarrow.simple_map
(
partition_key varchar,
secondary_key varchar,
ascii_col map<ascii, ascii>,
bigint_col map<bigint, bigint>,
blob_col map<blob, blob>,
boolean_col map<boolean, boolean>,
date_col map<date, date>,
double_col map<double, double>,
float_col map<float, float>,
int_col map<int, int>,
smallint_col map<smallint, smallint>,
text_col map<text, text>,
time_col map<time, time>,
timestamp_col map<timestamp, timestamp>,
tinyint_col map<tinyint, tinyint>,
varchar_col map<varchar, varchar>,
PRIMARY KEY (partition_key, secondary_key)
);
INSERT INTO cassarrow.simple_map JSON '
{
"partition_key": "test",
"secondary_key": "valid",
"ascii_col": {
"hello world":"hello world value"
},
"bigint_col": {
"1234567890": 1234567890
}
}
';