-
Notifications
You must be signed in to change notification settings - Fork 792
/
workflow_cql.go
668 lines (602 loc) · 19.6 KB
/
workflow_cql.go
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
// Copyright (c) 2021 Uber Technologies, Inc.
// Portions of the Software are attributed to Copyright (c) 2020 Temporal Technologies Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package cassandra
const (
templateWorkflowExecutionType = `{` +
`domain_id: ?, ` +
`workflow_id: ?, ` +
`run_id: ?, ` +
`first_run_id: ?, ` +
`parent_domain_id: ?, ` +
`parent_workflow_id: ?, ` +
`parent_run_id: ?, ` +
`initiated_id: ?, ` +
`completion_event_batch_id: ?, ` +
`completion_event: ?, ` +
`completion_event_data_encoding: ?, ` +
`task_list: ?, ` +
`workflow_type_name: ?, ` +
`workflow_timeout: ?, ` +
`decision_task_timeout: ?, ` +
`execution_context: ?, ` +
`state: ?, ` +
`close_status: ?, ` +
`last_first_event_id: ?, ` +
`last_event_task_id: ?, ` +
`next_event_id: ?, ` +
`last_processed_event: ?, ` +
`start_time: ?, ` +
`last_updated_time: ?, ` +
`create_request_id: ?, ` +
`signal_count: ?, ` +
`history_size: ?, ` +
`decision_version: ?, ` +
`decision_schedule_id: ?, ` +
`decision_started_id: ?, ` +
`decision_request_id: ?, ` +
`decision_timeout: ?, ` +
`decision_attempt: ?, ` +
`decision_timestamp: ?, ` +
`decision_scheduled_timestamp: ?, ` +
`decision_original_scheduled_timestamp: ?, ` +
`cancel_requested: ?, ` +
`cancel_request_id: ?, ` +
`sticky_task_list: ?, ` +
`sticky_schedule_to_start_timeout: ?,` +
`client_library_version: ?, ` +
`client_feature_version: ?, ` +
`client_impl: ?, ` +
`auto_reset_points: ?, ` +
`auto_reset_points_encoding: ?, ` +
`attempt: ?, ` +
`has_retry_policy: ?, ` +
`init_interval: ?, ` +
`backoff_coefficient: ?, ` +
`max_interval: ?, ` +
`expiration_time: ?, ` +
`max_attempts: ?, ` +
`non_retriable_errors: ?, ` +
`event_store_version: ?, ` +
`branch_token: ?, ` +
`cron_schedule: ?, ` +
`expiration_seconds: ?, ` +
`search_attributes: ?, ` +
`memo: ?, ` +
`partition_config: ? ` +
`}`
templateTransferTaskType = `{` +
`domain_id: ?, ` +
`workflow_id: ?, ` +
`run_id: ?, ` +
`visibility_ts: ?, ` +
`task_id: ?, ` +
`target_domain_id: ?, ` +
`target_domain_ids: ?,` +
`target_workflow_id: ?, ` +
`target_run_id: ?, ` +
`target_child_workflow_only: ?, ` +
`task_list: ?, ` +
`type: ?, ` +
`schedule_id: ?, ` +
`record_visibility: ?, ` +
`version: ?` +
`}`
templateCrossClusterTaskType = templateTransferTaskType
templateReplicationTaskType = `{` +
`domain_id: ?, ` +
`workflow_id: ?, ` +
`run_id: ?, ` +
`task_id: ?, ` +
`type: ?, ` +
`first_event_id: ?,` +
`next_event_id: ?,` +
`version: ?,` +
`scheduled_id: ?, ` +
`event_store_version: ?, ` +
`branch_token: ?, ` +
`new_run_event_store_version: ?, ` +
`new_run_branch_token: ?, ` +
`created_time: ? ` +
`}`
templateTimerTaskType = `{` +
`domain_id: ?, ` +
`workflow_id: ?, ` +
`run_id: ?, ` +
`visibility_ts: ?, ` +
`task_id: ?, ` +
`type: ?, ` +
`timeout_type: ?, ` +
`event_id: ?, ` +
`schedule_attempt: ?, ` +
`version: ?` +
`}`
templateActivityInfoType = `{` +
`version: ?, ` +
`schedule_id: ?, ` +
`scheduled_event_batch_id: ?, ` +
`scheduled_event: ?, ` +
`scheduled_time: ?, ` +
`started_id: ?, ` +
`started_event: ?, ` +
`started_time: ?, ` +
`activity_id: ?, ` +
`request_id: ?, ` +
`details: ?, ` +
`schedule_to_start_timeout: ?, ` +
`schedule_to_close_timeout: ?, ` +
`start_to_close_timeout: ?, ` +
`heart_beat_timeout: ?, ` +
`cancel_requested: ?, ` +
`cancel_request_id: ?, ` +
`last_hb_updated_time: ?, ` +
`timer_task_status: ?, ` +
`attempt: ?, ` +
`task_list: ?, ` +
`started_identity: ?, ` +
`has_retry_policy: ?, ` +
`init_interval: ?, ` +
`backoff_coefficient: ?, ` +
`max_interval: ?, ` +
`expiration_time: ?, ` +
`max_attempts: ?, ` +
`non_retriable_errors: ?, ` +
`last_failure_reason: ?, ` +
`last_worker_identity: ?, ` +
`last_failure_details: ?, ` +
`event_data_encoding: ?` +
`}`
templateTimerInfoType = `{` +
`version: ?, ` +
`timer_id: ?, ` +
`started_id: ?, ` +
`expiry_time: ?, ` +
`task_id: ?` +
`}`
templateChildExecutionInfoType = `{` +
`version: ?, ` +
`initiated_id: ?, ` +
`initiated_event_batch_id: ?, ` +
`initiated_event: ?, ` +
`started_id: ?, ` +
`started_workflow_id: ?, ` +
`started_run_id: ?, ` +
`started_event: ?, ` +
`create_request_id: ?, ` +
`event_data_encoding: ?, ` +
`domain_id: ?, ` +
`domain_name: ?, ` +
`workflow_type_name: ?, ` +
`parent_close_policy: ?` +
`}`
templateRequestCancelInfoType = `{` +
`version: ?,` +
`initiated_id: ?, ` +
`initiated_event_batch_id: ?, ` +
`cancel_request_id: ? ` +
`}`
templateSignalInfoType = `{` +
`version: ?, ` +
`initiated_id: ?, ` +
`initiated_event_batch_id: ?, ` +
`signal_request_id: ?, ` +
`signal_name: ?, ` +
`input: ?, ` +
`control: ?` +
`}`
templateChecksumType = `{` +
`version: ?, ` +
`flavor: ?, ` +
`value: ? ` +
`}`
templateUpdateCurrentWorkflowExecutionQuery = `UPDATE executions USING TTL 0 ` +
`SET current_run_id = ?, ` +
`execution = {run_id: ?, create_request_id: ?, state: ?, close_status: ?}, ` +
`workflow_last_write_version = ?, ` +
`workflow_state = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? ` +
`IF current_run_id = ? `
templateUpdateCurrentWorkflowExecutionForNewQuery = templateUpdateCurrentWorkflowExecutionQuery +
`and workflow_last_write_version = ? ` +
`and workflow_state = ? `
templateInsertWorkflowRequestQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, current_run_id) ` +
`VALUES(?, ?, ?, ?, ?, ?, ?, ?) IF NOT EXISTS USING TTL ?`
templateUpsertWorkflowRequestQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, current_run_id) ` +
`VALUES(?, ?, ?, ?, ?, ?, ?, ?) USING TTL ?`
templateGetLatestWorkflowRequestQuery = `SELECT current_run_id ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`LIMIT 1`
templateCreateCurrentWorkflowExecutionQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, current_run_id, execution, workflow_last_write_version, workflow_state) ` +
`VALUES(?, ?, ?, ?, ?, ?, ?, ?, {run_id: ?, create_request_id: ?, state: ?, close_status: ?}, ?, ?) IF NOT EXISTS USING TTL 0 `
templateCreateWorkflowExecutionWithVersionHistoriesQuery = `INSERT INTO executions (` +
`shard_id, domain_id, workflow_id, run_id, type, execution, next_event_id, visibility_ts, task_id, version_histories, version_histories_encoding, checksum, workflow_last_write_version, workflow_state) ` +
`VALUES(?, ?, ?, ?, ?, ` + templateWorkflowExecutionType + `, ?, ?, ?, ?, ?, ` + templateChecksumType + `, ?, ?) IF NOT EXISTS `
templateCreateTransferTaskQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, transfer, visibility_ts, task_id) ` +
`VALUES(?, ?, ?, ?, ?, ` + templateTransferTaskType + `, ?, ?)`
templateCreateCrossClusterTaskQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, cross_cluster, visibility_ts, task_id) ` +
`VALUES(?, ?, ?, ?, ?, ` + templateCrossClusterTaskType + `, ?, ?)`
templateCreateReplicationTaskQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, replication, visibility_ts, task_id) ` +
`VALUES(?, ?, ?, ?, ?, ` + templateReplicationTaskType + `, ?, ?)`
templateCreateTimerTaskQuery = `INSERT INTO executions (` +
`shard_id, type, domain_id, workflow_id, run_id, timer, visibility_ts, task_id) ` +
`VALUES(?, ?, ?, ?, ?, ` + templateTimerTaskType + `, ?, ?)`
templateUpdateLeaseQuery = `UPDATE executions ` +
`SET range_id = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? ` +
`IF range_id = ?`
// TODO: remove replication_state after all 2DC workflows complete
templateGetWorkflowExecutionQuery = `SELECT execution, replication_state, activity_map, timer_map, ` +
`child_executions_map, request_cancel_map, signal_map, signal_requested, buffered_events_list, ` +
`buffered_replication_tasks_map, version_histories, version_histories_encoding, checksum ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ?`
templateGetCurrentExecutionQuery = `SELECT current_run_id, execution, workflow_last_write_version ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ?`
templateListCurrentExecutionsQuery = `SELECT domain_id, workflow_id, run_id, current_run_id, workflow_state ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ?`
templateIsWorkflowExecutionExistsQuery = `SELECT shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ?`
templateListWorkflowExecutionQuery = `SELECT run_id, execution, version_histories, version_histories_encoding ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ?`
templateUpdateWorkflowExecutionWithVersionHistoriesQuery = `UPDATE executions ` +
`SET execution = ` + templateWorkflowExecutionType +
`, next_event_id = ? ` +
`, version_histories = ? ` +
`, version_histories_encoding = ? ` +
`, checksum = ` + templateChecksumType +
`, workflow_last_write_version = ? ` +
`, workflow_state = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? ` +
`IF next_event_id = ? `
templateUpdateActivityInfoQuery = `UPDATE executions ` +
`SET activity_map[ ? ] = ` + templateActivityInfoType + ` ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetActivityInfoQuery = `UPDATE executions ` +
`SET activity_map = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateUpdateTimerInfoQuery = `UPDATE executions ` +
`SET timer_map[ ? ] = ` + templateTimerInfoType + ` ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetTimerInfoQuery = `UPDATE executions ` +
`SET timer_map = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateUpdateChildExecutionInfoQuery = `UPDATE executions ` +
`SET child_executions_map[ ? ] = ` + templateChildExecutionInfoType + ` ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetChildExecutionInfoQuery = `UPDATE executions ` +
`SET child_executions_map = ?` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateUpdateRequestCancelInfoQuery = `UPDATE executions ` +
`SET request_cancel_map[ ? ] = ` + templateRequestCancelInfoType + ` ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetRequestCancelInfoQuery = `UPDATE executions ` +
`SET request_cancel_map = ?` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateUpdateSignalInfoQuery = `UPDATE executions ` +
`SET signal_map[ ? ] = ` + templateSignalInfoType + ` ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetSignalInfoQuery = `UPDATE executions ` +
`SET signal_map = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateUpdateSignalRequestedQuery = `UPDATE executions ` +
`SET signal_requested = signal_requested + ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateResetSignalRequestedQuery = `UPDATE executions ` +
`SET signal_requested = ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateAppendBufferedEventsQuery = `UPDATE executions ` +
`SET buffered_events_list = buffered_events_list + ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteBufferedEventsQuery = `UPDATE executions ` +
`SET buffered_events_list = [] ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteActivityInfoQuery = `DELETE activity_map[ ? ] ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteTimerInfoQuery = `DELETE timer_map[ ? ] ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteChildExecutionInfoQuery = `DELETE child_executions_map[ ? ] ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteRequestCancelInfoQuery = `DELETE request_cancel_map[ ? ] ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteSignalInfoQuery = `DELETE signal_map[ ? ] ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteWorkflowExecutionMutableStateQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateDeleteWorkflowExecutionCurrentRowQuery = templateDeleteWorkflowExecutionMutableStateQuery + " if current_run_id = ? "
templateDeleteWorkflowExecutionSignalRequestedQuery = `UPDATE executions ` +
`SET signal_requested = signal_requested - ? ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ? `
templateGetTransferTasksQuery = `SELECT transfer ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id > ? ` +
`and task_id <= ?`
templateGetCrossClusterTasksQuery = `SELECT cross_cluster ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id > ? ` +
`and task_id <= ?`
templateGetReplicationTasksQuery = `SELECT replication ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id > ? ` +
`and task_id <= ?`
templateGetDLQSizeQuery = `SELECT count(1) as count ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ?`
templateCompleteTransferTaskQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id = ?`
templateRangeCompleteTransferTaskQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id > ? ` +
`and task_id <= ?`
templateCompleteCrossClusterTaskQuery = templateCompleteTransferTaskQuery
templateRangeCompleteCrossClusterTaskQuery = templateRangeCompleteTransferTaskQuery
templateCompleteReplicationTaskBeforeQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ? ` +
`and run_id = ? ` +
`and visibility_ts = ? ` +
`and task_id <= ?`
templateCompleteReplicationTaskQuery = templateCompleteTransferTaskQuery
templateRangeCompleteReplicationTaskQuery = templateRangeCompleteTransferTaskQuery
templateGetTimerTasksQuery = `SELECT timer ` +
`FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ?` +
`and domain_id = ? ` +
`and workflow_id = ?` +
`and run_id = ?` +
`and visibility_ts >= ? ` +
`and visibility_ts < ?`
templateCompleteTimerTaskQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ?` +
`and run_id = ?` +
`and visibility_ts = ? ` +
`and task_id = ?`
templateRangeCompleteTimerTaskQuery = `DELETE FROM executions ` +
`WHERE shard_id = ? ` +
`and type = ? ` +
`and domain_id = ? ` +
`and workflow_id = ?` +
`and run_id = ?` +
`and visibility_ts >= ? ` +
`and visibility_ts < ?`
)