fluent-plugin-bigquery 0.5.0.beta1 → 0.5.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 440ecd282c8e8e724c5a1e0baa43aa88c0051f26
4
- data.tar.gz: 4e9767f4cfb54a6091dc25553dbb0190387b0d35
3
+ metadata.gz: 023c14a3ce8139a7b7cc9670ba7e5046e9d7407b
4
+ data.tar.gz: 7d5988af8f30c05149cb1f92770f72ab677074ce
5
5
  SHA512:
6
- metadata.gz: f57040773228cd0c73610251a6a67497750f5df9d232c9d61a1177056d709671b3e1e0970f6e6557422bc6885d16c10024bd3b79954c57a3e75846d419974d6a
7
- data.tar.gz: 1507120a4806737440d8666b57ea220df61076415adea45516d5feab651d3207bdbbb236c86ef579555226cbcb3a480c63260b361732ecb31a7cb6320aff9e7a
6
+ metadata.gz: 48327b0270d7fe66913fbabd04b6e09a3270808ff28d83cfcfde30f8985b333f493e007350d3f0cca7d495bd9d57856ad48f974f851781eed66cdb40b0f705f5
7
+ data.tar.gz: 8522ffdfc297465313938ee2c9d6fff5979c390b5c82e70e192774136288df19111db24b42d08654505e84e920776c2db4b1967bd989f2539d93a7b2741f58b7
data/README.md CHANGED
@@ -59,6 +59,7 @@ Because embbeded gem dependency sometimes restricts ruby environment.
59
59
  | replace_record_key_regexp{1-10} | string | no | no | nil | see examples. |
60
60
  | convert_hash_to_json | bool | no | no | false | If true, converts Hash value of record to JSON String. |
61
61
  | insert_id_field | string | no | no | nil | Use key as `insert_id` of Streaming Insert API parameter. |
62
+ | add_insert_timestamp | string | no | no | nil | Adds a timestamp column just before sending the rows to BigQuery, so that buffering time is not taken into account. Gives a field in BigQuery which represents the insert time of the row. |
62
63
  | allow_retry_insert_errors | bool | no | false | Retry to insert rows when an insertErrors occurs. There is a possibility that rows are inserted in duplicate. |
63
64
  | request_timeout_sec | integer | no | no | nil | Bigquery API response timeout |
64
65
  | request_open_timeout_sec | integer | no | no | 60 | Bigquery API connection, and request timeout. If you send big data to Bigquery, set large value. |
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module BigQueryPlugin
3
- VERSION = "0.5.0.beta1".freeze
3
+ VERSION = "0.5.0.beta2".freeze
4
4
  end
5
5
  end
@@ -113,9 +113,15 @@ module Fluent
113
113
  @client = nil
114
114
 
115
115
  reason = e.respond_to?(:reason) ? e.reason : nil
116
- log.error "tabledata.insertAll API", project_id: project, dataset: dataset, table: table_id, code: e.status_code, message: e.message, reason: reason
116
+ error_data = { project_id: project, dataset: dataset, table: table_id, code: e.status_code, message: e.message, reason: reason }
117
+ wrapped = Fluent::BigQuery::Error.wrap(e)
118
+ if wrapped.retryable?
119
+ log.warn "tabledata.insertAll API", error_data
120
+ else
121
+ log.error "tabledata.insertAll API", error_data
122
+ end
117
123
 
118
- raise Fluent::BigQuery::Error.wrap(e)
124
+ raise wrapped
119
125
  end
120
126
 
121
127
  def create_load_job(chunk_id, project, dataset, table_id, upload_source, fields)
@@ -118,6 +118,12 @@ module Fluent
118
118
  # prevent_duplicate_load (only load)
119
119
  config_param :prevent_duplicate_load, :bool, default: false
120
120
 
121
+ # add_insert_timestamp (only insert)
122
+ # adds a timestamp just before sending the rows to bigquery, so that
123
+ # buffering time is not taken into account. Gives a field in bigquery
124
+ # which represents the insert time of the row.
125
+ config_param :add_insert_timestamp, :string, default: nil
126
+
121
127
  config_param :method, :enum, list: [:insert, :load], default: :insert, skip_accessor: true
122
128
 
123
129
  # allow_retry_insert_errors (only insert)
@@ -398,9 +404,11 @@ module Fluent
398
404
 
399
405
  module InsertImplementation
400
406
  def _write(chunk, table_format)
407
+ now = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S.%6N") if @add_insert_timestamp
401
408
  rows = chunk.open do |io|
402
409
  io.map do |line|
403
410
  record = MultiJson.load(line)
411
+ record[@add_insert_timestamp] = now if @add_insert_timestamp
404
412
  row = {"json" => record}
405
413
  row["insert_id"] = @get_insert_id.call(record) if @get_insert_id
406
414
  row.deep_symbolize_keys
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta1
4
+ version: 0.5.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoya Ito
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-03 00:00:00.000000000 Z
12
+ date: 2017-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake