embulk-output-bigquery 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d48b65d07302466f8f52dadb559ad049a054453db3741d4384209125e7b9e9cd
4
- data.tar.gz: 13cd70568cfaebba819a9b7a9a51d1c45ff9f1599893b4a0b451e82dc84e40c9
3
+ metadata.gz: 5ad08405eb0d6f4a7ff867c6252d393628437d55e03fe33ec2cc71f940926153
4
+ data.tar.gz: 431ce1cf5298d5ec114a66191c9847f34fd554cc5de7c12fca8950a9e59538bf
5
5
  SHA512:
6
- metadata.gz: ee51c9bf570ce2f2a55e43a5ab7842f1669d814b93cdd1395853be8f6b3ff770f6a5a6c9f9a81b6c0eca1e9bc72aff3d1302d37760fe559ecfa33a740e1da724
7
- data.tar.gz: 8ada113513a089d786bf93bce1de98ad4bcc900ff73931c164a801b29e0bad9fd4b001bdf85962570998df995209e4ff320ba74e1fae22b61fb389a621121073
6
+ metadata.gz: c23e79e1b7e6d7b2af8455e97fd58bb4c4bc5e7b7fb1809bd49642294adfe644c27beca55177cff8427f5136532accae3973db1b000660c96f532e6d1cbfbc09
7
+ data.tar.gz: 2d6ee9d0cf3504683bc2898df3edc246401a2cfd44db2f6311368903e89e09e9b31e746232005fdbbf43f039b91ca1fe1b4f190704ceee3e7a9778962de5be1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.6.7 - 2021-09-10
2
+ * [enhancement] Add an expiration option of temporary table to clean up (thanks to @TKNGUE)
3
+
1
4
  ## 0.6.6 - 2021-06-10
2
5
 
3
6
  * [maintenance] Fix network retry function (thanks to @case-k-git)
data/README.md CHANGED
@@ -79,6 +79,13 @@ Options for intermediate local files
79
79
  | delete_from_local_when_job_end | boolean | optional | true | If set to true, delete generate local files when job is end |
80
80
  | compression | string | optional | "NONE" | Compression of local files (`GZIP` or `NONE`) |
81
81
 
82
+
83
+ Options for intermediate tables on BigQuery
84
+
85
+ | name | type | required? | default | description |
86
+ |:-------------------------------------|:------------|:-----------|:-------------------------|:-----------------------|
87
+ | temporary_table_expiration | integer | optional | | Temporary table's expiration time in seconds |
88
+
82
89
  `source_format` is also used to determine formatter (csv or jsonl).
83
90
 
84
91
  #### Same options of bq command-line tools or BigQuery job's property
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-output-bigquery"
3
- spec.version = "0.6.6"
3
+ spec.version = "0.6.7"
4
4
  spec.authors = ["Satoshi Akama", "Naotoshi Seo"]
5
5
  spec.summary = "Google BigQuery output plugin for Embulk"
6
6
  spec.description = "Embulk plugin that insert records to Google BigQuery."
@@ -440,6 +440,11 @@ module Embulk
440
440
  }
441
441
  end
442
442
 
443
+ if options['expiration_time']
444
+ # expiration_time is expressed in milliseconds
445
+ body[:expiration_time] = (Time.now.to_i + options['expiration_time']) * 1000
446
+ end
447
+
443
448
  opts = {}
444
449
  Embulk.logger.debug { "embulk-output-bigquery: insert_table(#{@project}, #{dataset}, #{@location_for_log}, #{body}, #{opts})" }
445
450
  with_network_retry { client.insert_table(@project, dataset, body, opts) }
@@ -90,6 +90,8 @@ module Embulk
90
90
  'clustering' => config.param('clustering', :hash, :default => nil), # google-api-ruby-client >= v0.21.0
91
91
  'schema_update_options' => config.param('schema_update_options', :array, :default => nil),
92
92
 
93
+ 'temporary_table_expiration' => config.param('temporary_table_expiration', :integer, :default => nil),
94
+
93
95
  # for debug
94
96
  'skip_load' => config.param('skip_load', :bool, :default => false),
95
97
  'temp_table' => config.param('temp_table', :string, :default => nil),
@@ -300,19 +302,23 @@ module Embulk
300
302
  end
301
303
  end
302
304
 
305
+ temp_table_expiration = task['temporary_table_expiration']
306
+ temp_options = {'expiration_time' => temp_table_expiration}
307
+
303
308
  case task['mode']
304
309
  when 'delete_in_advance'
305
310
  bigquery.delete_table_or_partition(task['table'])
306
311
  bigquery.create_table_if_not_exists(task['table'])
307
312
  when 'replace'
308
- bigquery.create_table_if_not_exists(task['temp_table'])
313
+ bigquery.create_table_if_not_exists(task['temp_table'], options: temp_options)
309
314
  bigquery.create_table_if_not_exists(task['table']) # needs for when task['table'] is a partition
310
315
  when 'append'
311
- bigquery.create_table_if_not_exists(task['temp_table'])
316
+ bigquery.create_table_if_not_exists(task['temp_table'], options: temp_options)
312
317
  bigquery.create_table_if_not_exists(task['table']) # needs for when task['table'] is a partition
313
318
  when 'replace_backup'
314
- bigquery.create_table_if_not_exists(task['temp_table'])
319
+ bigquery.create_table_if_not_exists(task['temp_table'], options: temp_options)
315
320
  bigquery.create_table_if_not_exists(task['table'])
321
+
316
322
  bigquery.create_table_if_not_exists(task['table_old'], dataset: task['dataset_old']) # needs for when a partition
317
323
  else # append_direct
318
324
  if task['auto_create_table']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-10 00:00:00.000000000 Z
12
+ date: 2021-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: signet