Skip to content

Commit d593f6d

Browse files
committed
patch table with retry
remove idea files
1 parent ac0dc0b commit d593f6d

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

.rakeTasks

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Settings><!--This file was automatically generated by Ruby plugin.
3+
You are allowed to:
4+
1. Remove rake task
5+
2. Add existing rake tasks
6+
To add existing rake tasks automatically delete this file and reload the project.
7+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>

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)