@@ -51,6 +51,7 @@ def test_partition_transform_execute(self, BigqueryServiceMock):
51
51
bigquery_service .transform_load .assert_called_with (query = final_query ,
52
52
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
53
53
destination_table = "bq_project.playground_dev.abcd$20190101" ,
54
+ dry_run = False ,
54
55
allow_field_addition = False )
55
56
56
57
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -90,6 +91,7 @@ def test_table_transform(self, BigqueryServiceMock):
90
91
bigquery_service .transform_load .assert_called_with (query = final_query ,
91
92
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
92
93
destination_table = "bq_project.playground_dev.abcd" ,
94
+ dry_run = False ,
93
95
allow_field_addition = False )
94
96
95
97
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -113,6 +115,7 @@ def test_single_partition_transform_1d_window_0_offset_without_spillover(self, B
113
115
bigquery_service .transform_load .assert_called_with (query = final_query ,
114
116
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
115
117
destination_table = "bq_project.playground_dev.abcd$20190101" ,
118
+ dry_run = False ,
116
119
allow_field_addition = False )
117
120
118
121
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -135,6 +138,7 @@ def test_single_partition_transform_2d_window_24h_offset_without_spillover(self,
135
138
bigquery_service .transform_load .assert_called_with (query = final_query ,
136
139
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
137
140
destination_table = "bq_project.playground_dev.abcd$20190104" ,
141
+ dry_run = False ,
138
142
allow_field_addition = False )
139
143
140
144
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -174,6 +178,7 @@ def test_single_partition_transform_7d_window_without_spillover(self, BigquerySe
174
178
bigquery_service .transform_load .assert_called_with (query = final_query ,
175
179
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
176
180
destination_table = "bq_project.playground_dev.abcd$20190103" ,
181
+ dry_run = False ,
177
182
allow_field_addition = False )
178
183
179
184
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -197,9 +202,11 @@ def test_single_partition_transform_2d_with_spillover(self, BigqueryServiceMock)
197
202
198
203
calls = [call (query = final_query_1 , write_disposition = WriteDisposition .WRITE_TRUNCATE ,
199
204
destination_table = "bq_project.playground_dev.abcd$20190103" ,
205
+ dry_run = False ,
200
206
allow_field_addition = False ),
201
207
call (query = final_query_2 , write_disposition = WriteDisposition .WRITE_TRUNCATE ,
202
208
destination_table = "bq_project.playground_dev.abcd$20190104" ,
209
+ dry_run = False ,
203
210
allow_field_addition = False )]
204
211
bigquery_service .transform_load .assert_has_calls (calls , any_order = True )
205
212
self .assertEqual (len (bigquery_service .transform_load .call_args_list ), len (calls ))
@@ -220,7 +227,7 @@ def test_dml_transform(self, BigqueryServiceMock):
220
227
task .execute ()
221
228
222
229
final_query = """select count(1) from table where date >= '2019-01-02' and date < '2019-01-03'"""
223
- bigquery_service .execute_query .assert_called_with (final_query )
230
+ bigquery_service .execute_query .assert_called_with (final_query , dry_run = False )
224
231
225
232
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
226
233
def test_execute_dry_run (self , BigqueryServiceMock ):
@@ -237,7 +244,13 @@ def test_execute_dry_run(self, BigqueryServiceMock):
237
244
task = TableTransformation (bigquery_service , task_config , query , localized_start_time ,
238
245
localized_end_time , dry_run , localized_execution_time )
239
246
task .transform ()
240
- bigquery_service .transform_load .assert_not_called ()
247
+
248
+ final_query = "select count(1) from table where date >= '2019-01-01 00:00:00' and date < '2019-01-01 00:00:00'"
249
+ bigquery_service .transform_load .assert_called_with (query = final_query ,
250
+ write_disposition = WriteDisposition .WRITE_TRUNCATE ,
251
+ destination_table = "bq_project.playground_dev.abcd" ,
252
+ dry_run = True ,
253
+ allow_field_addition = False )
241
254
242
255
243
256
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -262,6 +275,7 @@ def test_allow_field_addition(self, BigqueryServiceMock):
262
275
bigquery_service .transform_load .assert_called_with (query = final_query ,
263
276
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
264
277
destination_table = "bq_project.playground_dev.abcd" ,
278
+ dry_run = False ,
265
279
allow_field_addition = True )
266
280
267
281
@@ -289,7 +303,7 @@ def test_should_run_dml_merge_statements(self, BigqueryServiceMock):
289
303
transformation .transform ()
290
304
291
305
final_query = """select count(1) from table where date >= '2019-02-01' and date < '2019-02-02'"""
292
- bigquery_service .execute_query .assert_called_with (final_query )
306
+ bigquery_service .execute_query .assert_called_with (final_query , dry_run = False )
293
307
294
308
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
295
309
def test_should_run_table_task (self , BigqueryServiceMock ):
@@ -325,6 +339,7 @@ def get_table_mock(table_name):
325
339
bigquery_service .transform_load .assert_called_with (query = final_query ,
326
340
write_disposition = WriteDisposition .WRITE_APPEND ,
327
341
destination_table = "bq_project.playground_dev.abcd" ,
342
+ dry_run = False ,
328
343
allow_field_addition = False )
329
344
330
345
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -362,6 +377,7 @@ def get_table_mock(table_name):
362
377
bigquery_service .transform_load .assert_called_with (query = final_query ,
363
378
write_disposition = WriteDisposition .WRITE_TRUNCATE ,
364
379
destination_table = "bq_project.playground_dev.abcd" ,
380
+ dry_run = False ,
365
381
allow_field_addition = False )
366
382
367
383
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
@@ -401,7 +417,7 @@ def get_table_mock(table_name):
401
417
transformation .transform ()
402
418
403
419
final_query = """-- Optimus generated\n DECLARE partitions ARRAY<DATE>;\n \n \n \n CREATE TEMP TABLE `opt__partitions` AS (\n select count(1) from table where date >= '__dstart__' and date < '__dend__'\n );\n \n SET (partitions) = (\n SELECT AS STRUCT\n array_agg(DISTINCT DATE(`event_timestamp`))\n FROM opt__partitions\n );\n \n MERGE INTO\n `bq_project.playground_dev.abcd` AS target\n USING\n (\n Select * from `opt__partitions`\n ) AS source\n ON FALSE\n WHEN NOT MATCHED BY SOURCE AND DATE(`event_timestamp`) IN UNNEST(partitions)\n THEN DELETE\n WHEN NOT MATCHED THEN INSERT\n (\n \n )\n VALUES\n (\n \n );\n """
404
- bigquery_service .execute_query .assert_called_with (final_query )
420
+ bigquery_service .execute_query .assert_called_with (final_query , dry_run = False )
405
421
406
422
@mock .patch ("bumblebee.bigquery_service.BigqueryService" )
407
423
def test_should_fail_if_partition_task_for_ingestion_time_without_filter_in_REPLACE_MERGE (self , BigqueryServiceMock ):
0 commit comments