@@ -179,6 +179,7 @@ def do_write(
179
179
project_id : Optional [str ] = None ,
180
180
dataset : Optional [str ] = None ,
181
181
max_retry_cnt : Optional [int ] = DEFAULT_MAX_RETRY_CNT ,
182
+ overwrite_table : Optional [bool ] = True ,
182
183
) -> List [ObjectRef [WriteResult ]]:
183
184
def _write_single_block (
184
185
block : Block , metadata : BlockMetadata , project_id : str , dataset : str
@@ -251,16 +252,22 @@ def _write_single_block(
251
252
dataset_id = dataset .split ("." , 1 )[0 ]
252
253
try :
253
254
client .get_dataset (dataset_id )
254
- print (
255
- f"[Ray on Vertex AI]: Dataset { dataset_id } already exists."
256
- + "The table will be overwritten if it already exists."
257
- )
258
255
except exceptions .NotFound :
259
256
client .create_dataset (f"{ project_id } .{ dataset_id } " , timeout = 30 )
260
257
print (f"[Ray on Vertex AI]: Created dataset { dataset_id } " )
261
258
262
- # Delete table if it already exists
263
- client .delete_table (f"{ project_id } .{ dataset } " , not_found_ok = True )
259
+ # Delete table if overwrite_table is True
260
+ if overwrite_table :
261
+ print (
262
+ f"[Ray on Vertex AI]: Attempting to delete table { dataset } "
263
+ + " if it already exists since kwarg overwrite_table = True."
264
+ )
265
+ client .delete_table (f"{ project_id } .{ dataset } " , not_found_ok = True )
266
+ else :
267
+ print (
268
+ f"[Ray on Vertex AI]: The write will append to table { dataset } "
269
+ + " if it already exists since kwarg overwrite_table = False."
270
+ )
264
271
265
272
print ("[Ray on Vertex AI]: Writing" , len (blocks ), "blocks" )
266
273
for i in range (len (blocks )):
0 commit comments