Skip to content

Commit 9a16dea

Browse files
authored
Merge pull request #16 from trocco-io/patch_table_with_retry
2 parents ac0dc0b + f83b894 commit 9a16dea

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/embulk/output/bigquery/bigquery_client.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -514,26 +514,28 @@ def get_table_or_partition(table, dataset: nil)
514514

515515
# update only column.description
516516
def patch_table
517-
table = get_table(@task['table'])
518-
519-
def patch_description(fields, column_options)
520-
fields.map do |field|
521-
column_option = column_options.select{|col_opt| col_opt['name'] == field.name}.first
522-
if column_option
523-
field.update!(description: column_option['description']) if column_option['description']
524-
if field.fields && column_option['fields']
525-
nested_fields = patch_description(field.fields, column_option['fields'])
526-
field.update!(fields: nested_fields)
517+
with_job_retry do
518+
table = get_table(@task['table'])
519+
520+
def patch_description(fields, column_options)
521+
fields.map do |field|
522+
column_option = column_options.select{|col_opt| col_opt['name'] == field.name}.first
523+
if column_option
524+
field.update!(description: column_option['description']) if column_option['description']
525+
if field.fields && column_option['fields']
526+
nested_fields = patch_description(field.fields, column_option['fields'])
527+
field.update!(fields: nested_fields)
528+
end
527529
end
530+
field
528531
end
529-
field
530532
end
531-
end
532533

533-
fields = patch_description(table.schema.fields, @task['column_options'])
534-
table.schema.update!(fields: fields)
535-
table_id = Helper.chomp_partition_decorator(@task['table'])
536-
client.patch_table(@project, @dataset, table_id, table)
534+
fields = patch_description(table.schema.fields, @task['column_options'])
535+
table.schema.update!(fields: fields)
536+
table_id = Helper.chomp_partition_decorator(@task['table'])
537+
with_network_retry { client.patch_table(@project, @dataset, table_id, table) }
538+
end
537539
end
538540
end
539541
end

0 commit comments

Comments
 (0)