@@ -90,6 +90,8 @@ def self.configure(config, schema, task_count)
90
90
'clustering' => config . param ( 'clustering' , :hash , :default => nil ) , # google-api-ruby-client >= v0.21.0
91
91
'schema_update_options' => config . param ( 'schema_update_options' , :array , :default => nil ) ,
92
92
93
+ 'temporary_table_expiration' => config . param ( 'temporary_table_expiration' , :integer , :default => nil ) ,
94
+
93
95
# for debug
94
96
'skip_load' => config . param ( 'skip_load' , :bool , :default => false ) ,
95
97
'temp_table' => config . param ( 'temp_table' , :string , :default => nil ) ,
@@ -300,19 +302,23 @@ def self.auto_create(task, bigquery)
300
302
end
301
303
end
302
304
305
+ temp_table_expiration = task [ 'temporary_table_expiration' ]
306
+ temp_options = { 'expiration_time' => temp_table_expiration }
307
+
303
308
case task [ 'mode' ]
304
309
when 'delete_in_advance'
305
310
bigquery . delete_table_or_partition ( task [ 'table' ] )
306
311
bigquery . create_table_if_not_exists ( task [ 'table' ] )
307
312
when 'replace'
308
- bigquery . create_table_if_not_exists ( task [ 'temp_table' ] )
313
+ bigquery . create_table_if_not_exists ( task [ 'temp_table' ] , options : temp_options )
309
314
bigquery . create_table_if_not_exists ( task [ 'table' ] ) # needs for when task['table'] is a partition
310
315
when 'append'
311
- bigquery . create_table_if_not_exists ( task [ 'temp_table' ] )
316
+ bigquery . create_table_if_not_exists ( task [ 'temp_table' ] , options : temp_options )
312
317
bigquery . create_table_if_not_exists ( task [ 'table' ] ) # needs for when task['table'] is a partition
313
318
when 'replace_backup'
314
- bigquery . create_table_if_not_exists ( task [ 'temp_table' ] )
319
+ bigquery . create_table_if_not_exists ( task [ 'temp_table' ] , options : temp_options )
315
320
bigquery . create_table_if_not_exists ( task [ 'table' ] )
321
+
316
322
bigquery . create_table_if_not_exists ( task [ 'table_old' ] , dataset : task [ 'dataset_old' ] ) # needs for when a partition
317
323
else # append_direct
318
324
if task [ 'auto_create_table' ]
0 commit comments