embulk-input-bigquery 0.0.5 → 0.0.6

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
- SHA1:
3
- metadata.gz: 6d1843ddd992acd60c5fae63ca9e4708dfb695aa
4
- data.tar.gz: 90a6c3aa9442c569537badeda3431d506aeb351d
2
+ SHA256:
3
+ metadata.gz: efd02ce4fc80435c9c8201987b371039e9b95bd0c3cbcffb36e57abb7b7ebb84
4
+ data.tar.gz: 4b5569cb00d85d942294f394288458cec16717f730044d5abe302ac280041ddf
5
5
  SHA512:
6
- metadata.gz: eb4b870643c699b2046d9a5274dea51d243387f777ca7aa1817d0702728633f4aa8b8446ec36180dee8ee043a204209060cbaba8aba76ff5cb68f1f58bac606e
7
- data.tar.gz: 84c0b47cca1b3e396d4dad22f4f11e668e00b7a5107b950bee4857b68f9a4df24f6353d1103be4e55fc3223c81025a9f5a147f9583076cf65cb36ba0f7217083
6
+ metadata.gz: f196cd00abd736c0ed95d9619af52035256e75685fb4e9c519dc3eb99aa566e61e1bc6096f01e701bbe74afa4618efbdecb3d4042745dce16abdd34990a3d6e2
7
+ data.tar.gz: 89acc43d7c8f4add08b92235302936962ff55feb3c6dc50484b2866d97eaeac0b0b31751149761089657e2a079ae1330437b7e98c75aa0c1b0128522ded7fb9f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.0.6 (2018/05/16)
2
+
3
+ * Support location option to allow to use location other than the US or EU multi-region.
4
+
1
5
  # 0.0.5 (2018/05/14)
2
6
 
3
7
  * Allow google-cloud-bigquery version between v0.24 and v1.5.0
data/README.md CHANGED
@@ -22,6 +22,7 @@ This plugin uses the gem [`google-cloud(Google Cloud Client Library for Ruby)`](
22
22
  | cache | boolean | optional | true | Whether to look for the result in the query cache. The query cache is a best-effort cache that will be flushed whenever tables in the query are modified. The default value is true. For more information, see [query caching](https://developers.google.com/bigquery/querying-data). |
23
23
  | standard\_sql | boolean | optional | true | Specifies whether to use BigQuery's [standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/) dialect for this query. If set to true, the query will use standard SQL rather than the [legacy SQL](https://cloud.google.com/bigquery/docs/reference/legacy-sql) dialect. When set to true, the values of `large_results` and `flatten` are ignored; the query will be run as if `large_results` is true and `flatten` is false. Optional. The default value is true. |
24
24
  | legacy\_sql | boolean | optional | false | legacy_sql Specifies whether to use BigQuery's [legacy SQL](https://cloud.google.com/bigquery/docs/reference/legacy-sql) dialect for this query. If set to false, the query will use BigQuery's [standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/) When set to false, the values of `large_results` and `flatten` are ignored; the query will be run as if `large_results` is true and `flatten` is false. Optional. The default value is false. |
25
+ | location | string | optional | `null` | If your data is in a location other than the US or EU multi-region, you must specify the location. See also [Dataset Locations | BigQuery | Google Cloud](https://cloud.google.com/bigquery/docs/dataset-locations) |
25
26
 
26
27
  ## Example
27
28
 
@@ -35,6 +36,9 @@ in:
35
36
  - {name: price, type: long}
36
37
  - {name: category_id, type: string}
37
38
  max: 2000
39
+
40
+ # # If your data is in a location other than the US or EU multi-region, you must specify the location.
41
+ # location: asia-northeast1
38
42
  out:
39
43
  type: stdout
40
44
  ```
@@ -43,7 +43,8 @@ module Embulk
43
43
  max: config[:max],
44
44
  cache: config[:cache],
45
45
  standard_sql: config[:standard_sql],
46
- legacy_sql: config[:legacy_sql]
46
+ legacy_sql: config[:legacy_sql],
47
+ location: config[:location],
47
48
  }
48
49
  }
49
50
 
@@ -74,9 +75,17 @@ module Embulk
74
75
  option = keys_to_sym(@task[:option])
75
76
 
76
77
  rows = if @task[:job_id].nil?
77
- bq.query(@task[:sql], **option)
78
+ query_option = option.dup
79
+ query_option.delete(:location)
80
+
81
+ bq.query(@task[:sql], **query_option) do |job_updater|
82
+ job_updater.location = option[:location] if option[:location]
83
+ end
78
84
  else
79
- bq.job(@task[:job_id]).query_results(max: option[:max])
85
+ job_option = {}
86
+ job_option[:location] = option[:location] if option[:location]
87
+
88
+ bq.job(@task[:job_id], **job_option).query_results(max: option[:max])
80
89
  end
81
90
 
82
91
  @task[:columns] = values_to_sym(@task[:columns], 'name')
@@ -99,9 +108,12 @@ module Embulk
99
108
  def self.determine_columns_by_query_results(sql, option, bigquery_client)
100
109
  Embulk.logger.info 'determine columns using the getQueryResults API instead of the config.yml'
101
110
 
102
- filtered_option = option.dup
103
- filtered_option.delete(:max)
104
- job = bigquery_client.query_job(sql, **filtered_option)
111
+ query_option = option.dup
112
+ query_option.delete(:max)
113
+ query_option.delete(:location)
114
+ job = bigquery_client.query_job(sql, **query_option) do |query|
115
+ query.location = option[:location] if option[:location]
116
+ end
105
117
 
106
118
  Embulk.logger.info 'waiting for the query job to complete to get schema from query results'
107
119
  job.wait_until_done!
@@ -1,7 +1,7 @@
1
1
  module Embulk
2
2
  module Input
3
3
  module Bigquery
4
- VERSION = '0.0.5'.freeze
4
+ VERSION = '0.0.6'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - potato2003
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-05-14 00:00:00.000000000 Z
13
+ date: 2018-05-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: google-cloud-bigquery
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.6.11
101
+ rubygems_version: 2.7.6
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Embulk input plugin from bigquery.