@@ -180,18 +180,19 @@ def test_list_datasets(self):
180
180
181
181
def test_create_table (self ):
182
182
dataset = self .temp_dataset (_make_dataset_id ('create_table' ))
183
-
184
- TABLE_NAME = 'test_table'
183
+ table_id = 'test_table'
185
184
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
186
185
mode = 'REQUIRED' )
187
186
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
188
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
189
- client = Config .CLIENT )
190
- self .assertFalse (table .exists ())
191
- table .create ()
187
+ table_arg = Table (dataset .table (table_id ), schema = [full_name , age ],
188
+ client = Config .CLIENT )
189
+ self .assertFalse (table_arg .exists ())
190
+
191
+ table = retry_403 (Config .CLIENT .create_table )(table_arg )
192
192
self .to_delete .insert (0 , table )
193
+
193
194
self .assertTrue (table .exists ())
194
- self .assertEqual (table .table_id , TABLE_NAME )
195
+ self .assertEqual (table .table_id , table_id )
195
196
196
197
def test_get_table_w_public_dataset (self ):
197
198
PUBLIC = 'bigquery-public-data'
@@ -227,10 +228,10 @@ def test_list_dataset_tables(self):
227
228
mode = 'REQUIRED' )
228
229
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
229
230
for table_name in tables_to_create :
230
- created_table = Table (dataset .table (table_name ),
231
- schema = [full_name , age ],
232
- client = Config .CLIENT )
233
- created_table . create ( )
231
+ table = Table (dataset .table (table_name ),
232
+ schema = [full_name , age ],
233
+ client = Config .CLIENT )
234
+ created_table = retry_403 ( Config . CLIENT . create_table )( table )
234
235
self .to_delete .insert (0 , created_table )
235
236
236
237
# Retrieve the tables.
@@ -249,10 +250,10 @@ def test_patch_table(self):
249
250
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
250
251
mode = 'REQUIRED' )
251
252
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
252
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
253
- client = Config .CLIENT )
254
- self .assertFalse (table .exists ())
255
- table . create ( )
253
+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
254
+ client = Config .CLIENT )
255
+ self .assertFalse (table_arg .exists ())
256
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
256
257
self .to_delete .insert (0 , table )
257
258
self .assertTrue (table .exists ())
258
259
self .assertIsNone (table .friendly_name )
@@ -268,10 +269,10 @@ def test_update_table(self):
268
269
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
269
270
mode = 'REQUIRED' )
270
271
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
271
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
272
- client = Config .CLIENT )
273
- self .assertFalse (table .exists ())
274
- table . create ( )
272
+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
273
+ client = Config .CLIENT )
274
+ self .assertFalse (table_arg .exists ())
275
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
275
276
self .to_delete .insert (0 , table )
276
277
self .assertTrue (table .exists ())
277
278
voter = bigquery .SchemaField ('voter' , 'BOOLEAN' , mode = 'NULLABLE' )
@@ -309,10 +310,10 @@ def test_insert_data_then_dump_table(self):
309
310
mode = 'REQUIRED' )
310
311
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
311
312
now = bigquery .SchemaField ('now' , 'TIMESTAMP' )
312
- table = Table (dataset .table (TABLE_NAME ), schema = [ full_name , age , now ] ,
313
- client = Config .CLIENT )
314
- self .assertFalse (table .exists ())
315
- table . create ( )
313
+ table_arg = Table (dataset .table (TABLE_NAME ),
314
+ schema = [ full_name , age , now ], client = Config .CLIENT )
315
+ self .assertFalse (table_arg .exists ())
316
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
316
317
self .to_delete .insert (0 , table )
317
318
self .assertTrue (table .exists ())
318
319
@@ -346,9 +347,9 @@ def test_load_table_from_local_file_then_dump_table(self):
346
347
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
347
348
mode = 'REQUIRED' )
348
349
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
349
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
350
- client = Config .CLIENT )
351
- table . create ( )
350
+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
351
+ client = Config .CLIENT )
352
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
352
353
self .to_delete .insert (0 , table )
353
354
354
355
with _NamedTemporaryFile () as temp :
@@ -450,9 +451,9 @@ def test_load_table_from_storage_then_dump_table(self):
450
451
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
451
452
mode = 'REQUIRED' )
452
453
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
453
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
454
- client = Config .CLIENT )
455
- table . create ( )
454
+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
455
+ client = Config .CLIENT )
456
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
456
457
self .to_delete .insert (0 , table )
457
458
458
459
job = Config .CLIENT .load_table_from_storage (
@@ -652,9 +653,9 @@ def test_job_cancel(self):
652
653
full_name = bigquery .SchemaField ('full_name' , 'STRING' ,
653
654
mode = 'REQUIRED' )
654
655
age = bigquery .SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
655
- table = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
656
- client = Config .CLIENT )
657
- table . create ( )
656
+ table_arg = Table (dataset .table (TABLE_NAME ), schema = [full_name , age ],
657
+ client = Config .CLIENT )
658
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
658
659
self .to_delete .insert (0 , table )
659
660
660
661
job = Config .CLIENT .run_async_query (JOB_NAME , QUERY )
@@ -839,9 +840,9 @@ def _load_table_for_dml(self, rows, dataset_id, table_id):
839
840
dataset = self .temp_dataset (dataset_id )
840
841
greeting = bigquery .SchemaField (
841
842
'greeting' , 'STRING' , mode = 'NULLABLE' )
842
- table = Table (dataset .table (table_id ), schema = [greeting ],
843
- client = Config .CLIENT )
844
- table . create ( )
843
+ table_arg = Table (dataset .table (table_id ), schema = [greeting ],
844
+ client = Config .CLIENT )
845
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
845
846
self .to_delete .insert (0 , table )
846
847
847
848
with _NamedTemporaryFile () as temp :
@@ -1228,9 +1229,9 @@ def test_insert_nested_nested(self):
1228
1229
]
1229
1230
table_name = 'test_table'
1230
1231
dataset = self .temp_dataset (_make_dataset_id ('issue_2951' ))
1231
- table = Table (dataset .table (table_name ), schema = schema ,
1232
- client = Config .CLIENT )
1233
- table . create ( )
1232
+ table_arg = Table (dataset .table (table_name ), schema = schema ,
1233
+ client = Config .CLIENT )
1234
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
1234
1235
self .to_delete .insert (0 , table )
1235
1236
1236
1237
table .insert_data (to_insert )
@@ -1245,9 +1246,9 @@ def test_create_table_insert_fetch_nested_schema(self):
1245
1246
dataset = self .temp_dataset (
1246
1247
_make_dataset_id ('create_table_nested_schema' ))
1247
1248
schema = _load_json_schema ()
1248
- table = Table (dataset .table (table_name ), schema = schema ,
1249
- client = Config .CLIENT )
1250
- table . create ( )
1249
+ table_arg = Table (dataset .table (table_name ), schema = schema ,
1250
+ client = Config .CLIENT )
1251
+ table = retry_403 ( Config . CLIENT . create_table )( table_arg )
1251
1252
self .to_delete .insert (0 , table )
1252
1253
self .assertTrue (table .exists ())
1253
1254
self .assertEqual (table .table_id , table_name )
0 commit comments