lib/fluent/plugin/bigquery/writer.rb in fluent-plugin-bigquery-0.3.3 vs lib/fluent/plugin/bigquery/writer.rb in fluent-plugin-bigquery-0.3.4

- old
+ new

@@ -23,10 +23,11 @@ def create_table(project, dataset, table_id, record_schema, time_partitioning_type: nil, time_partitioning_expiration: nil) create_table_retry_limit = 3 create_table_retry_wait = 1 create_table_retry_count = 0 + table_id = safe_table_id(table_id) begin definition = { table_reference: { table_id: table_id, @@ -91,11 +92,11 @@ body.merge!(template_suffix: template_suffix) if template_suffix res = client.insert_all_table_data(project, dataset, table_id, body, { options: {timeout_sec: timeout_sec, open_timeout_sec: open_timeout_sec} }) log.debug "insert rows", project_id: project, dataset: dataset, table: table_id, count: rows.size - log.warn "insert errors", insert_errors: res.insert_errors.to_s if res.insert_errors && !res.insert_errors.empty? + log.warn "insert errors", project_id: project, dataset: dataset, table: table_id, insert_errors: res.insert_errors.to_s if res.insert_errors && !res.insert_errors.empty? rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e @client = nil reason = e.respond_to?(:reason) ? e.reason : nil log.error "tabledata.insertAll API", project_id: project, dataset: dataset, table: table_id, code: e.status_code, message: e.message, reason: reason @@ -251,9 +252,13 @@ end end def get_auth_from_application_default Google::Auth.get_application_default([@scope]) + end + + def safe_table_id(table_id) + table_id.gsub(/\$\d+$/, "") end end end end