Skip to content

Commit b20fc4e

Browse files
Merge pull request #148 from kashira202111/kashira/fix_create_table_to_destination_project
Prevent creating unnecessary tables.
2 parents 2df3150 + 5ed9f0d commit b20fc4e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/embulk/output/bigquery/bigquery_client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ def create_table_if_not_exists(table, dataset: nil, options: nil)
447447
end
448448

449449
opts = {}
450-
Embulk.logger.debug { "embulk-output-bigquery: insert_table(#{@project}, #{dataset}, #{@location_for_log}, #{body}, #{opts})" }
451-
with_network_retry { client.insert_table(@project, dataset, body, **opts) }
450+
Embulk.logger.debug { "embulk-output-bigquery: insert_table(#{@destination_project}, #{dataset}, #{@location_for_log}, #{body}, #{opts})" }
451+
with_network_retry { client.insert_table(@destination_project, dataset, body, **opts) }
452452
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
453453
if e.status_code == 409 && /Already Exists:/ =~ e.message
454454
# ignore 'Already Exists' error
@@ -457,7 +457,7 @@ def create_table_if_not_exists(table, dataset: nil, options: nil)
457457

458458
response = {status_code: e.status_code, message: e.message, error_class: e.class}
459459
Embulk.logger.error {
460-
"embulk-output-bigquery: insert_table(#{@project}, #{dataset}, #{@location_for_log}, #{body}, #{opts}), response:#{response}"
460+
"embulk-output-bigquery: insert_table(#{@destination_project}, #{dataset}, #{@location_for_log}, #{body}, #{opts}), response:#{response}"
461461
}
462462
raise Error, "failed to create table #{@destination_project}:#{dataset}.#{table} in #{@location_for_log}, response:#{response}"
463463
end

0 commit comments

Comments
 (0)