dwh 0.6.1 → 0.6.3

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
  SHA256:
3
- metadata.gz: 1bb280be5e0be9e979828b1e35d8271dbfd35f6926cedcac3c9c134140ca8b30
4
- data.tar.gz: 407efc9f63ce81f8bb166d970d5ee2d43e8cd31e1fe41f62802362ddc02653e7
3
+ metadata.gz: 67b6a93cc25d2b207d3612ba6d6a7608e1c3cb58c13faea7252cba8940ee7035
4
+ data.tar.gz: 98f9e66b24d87dd33291d61b1faac372d1f10e78af4e46e14153c7a389bb23e5
5
5
  SHA512:
6
- metadata.gz: 8773bba3799deb57bd3e3e4738287ded1f0bd8f32fc1225490f346076676f3c962dc58ad43a697e87dc86b41ce10f563af6ac0a1eb3f1ca84836ea9d468cf29d
7
- data.tar.gz: af66e29a860e89af3c5f8794df099a622d3baa4f7ea5576076c1856399cc91838e3ecdf85ed70c038a8f8061b8da2e65bffc2f49ceca0596ac0457f5b35dfb46
6
+ metadata.gz: a1130401373c8a13df8bd44cbe654e8ca00481f59ad97815810ce766fddc1de7f41ca0b3951b961b99523e0ab5621c51f029d14611972d6e481d87f757b13651
7
+ data.tar.gz: 3af020dc6bada0931d5aa2d2eb906125c3042534ffde0424fb4e4b37743663af4a8b61490f8009b93a48a03fe67dbd107658a808b3451c02e5ff9a5f685f0d34
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.3] - 2026-09-30
4
+
5
+ ### Fixed
6
+
7
+ - **BigQuery**: `close` no longer calls `close` on the Google client, which has none. Pool shutdown (for example when a datasource config changes) raised `undefined method close`.
8
+
9
+ ## [0.6.2] - 2026-09-30
10
+
11
+ ### Added
12
+
13
+ - **BigQuery**: `client_email` and `private_key` config accept the service-account keyfile's fields inline, so a server can connect without the JSON file on disk. `keyfile` and Application Default Credentials keep working.
14
+
3
15
  ## [0.6.1] - 2026-09-30
4
16
 
5
17
  ### Fixed
data/README.md CHANGED
@@ -153,4 +153,4 @@ This project is available as open source under the terms of the MIT License.
153
153
 
154
154
  ## Version
155
155
 
156
- Current version: 0.6.1
156
+ Current version: 0.6.3
@@ -705,12 +705,14 @@ Requires the `google-cloud-bigquery` gem (`gem install google-cloud-bigquery`, p
705
705
  bq = DWH.create(:bigquery, {
706
706
  project_id: 'my-gcp-project',
707
707
  dataset: 'analytics', # default dataset for unqualified table names
708
- keyfile: '/path/to/service-account.json', # optional; omit to use Application Default Credentials
708
+ keyfile: '/path/to/service-account.json', # optional; or pass the keyfile's fields inline:
709
+ # client_email: 'svc@my-gcp-project.iam.gserviceaccount.com',
710
+ # private_key: "-----BEGIN PRIVATE KEY-----\n...",
709
711
  query_timeout: 300 # optional, seconds
710
712
  })
711
713
  ```
712
714
 
713
- Without `keyfile`, credentials resolve via `GOOGLE_APPLICATION_CREDENTIALS` or `gcloud auth application-default login`.
715
+ `client_email` + `private_key` (the two fields the keyfile holds) let a server connect without the file on disk and take precedence over `keyfile`. Without either, credentials resolve via `GOOGLE_APPLICATION_CREDENTIALS` or `gcloud auth application-default login`.
714
716
  Extra client options can be passed with `extra_connection_params` (see `Google::Cloud::Bigquery.new`).
715
717
 
716
718
  ## Configuration Validation
@@ -13,6 +13,14 @@ module DWH
13
13
  # keyfile: '/path/to/service-account.json'
14
14
  # })
15
15
  #
16
+ # @example Inline service-account credentials (the keyfile's client_email and private_key)
17
+ # DWH.create(:bigquery, {
18
+ # project_id: 'my-gcp-project',
19
+ # dataset: 'analytics',
20
+ # client_email: 'svc@my-gcp-project.iam.gserviceaccount.com',
21
+ # private_key: "-----BEGIN PRIVATE KEY-----\n..."
22
+ # })
23
+ #
16
24
  # @example Application Default Credentials (gcloud auth application-default login)
17
25
  # DWH.create(:bigquery, { project_id: 'my-gcp-project', dataset: 'analytics' })
18
26
  class BigQuery < Adapter
@@ -20,6 +28,10 @@ module DWH
20
28
  config :dataset, String, required: true, message: 'default dataset for unqualified table names'
21
29
  config :keyfile, String, required: false, default: nil,
22
30
  message: 'path to service-account JSON; omit to use Application Default Credentials'
31
+ config :client_email, String, required: false, default: nil,
32
+ message: 'service-account email from the keyfile; use with private_key instead of keyfile'
33
+ config :private_key, String, required: false, default: nil,
34
+ message: 'service-account private key (PEM) from the keyfile; use with client_email'
23
35
  config :query_timeout, Integer, required: false, default: 300, message: 'query timeout in seconds'
24
36
 
25
37
  # The schema API reports legacy type names; map the ones whose
@@ -43,7 +55,8 @@ module DWH
43
55
 
44
56
  require 'google/cloud/bigquery'
45
57
  opts = { project_id: config[:project_id] }
46
- opts[:credentials] = config[:keyfile] unless config[:keyfile].to_s.empty?
58
+ creds = google_credentials
59
+ opts[:credentials] = creds if creds
47
60
  @connection = Google::Cloud::Bigquery.new(**opts, **extra_connection_params)
48
61
  rescue LoadError
49
62
  raise ConfigError, <<~MSG
@@ -57,6 +70,12 @@ module DWH
57
70
  raise ConfigError, "Failed to connect to BigQuery: #{e.message}"
58
71
  end
59
72
 
73
+ # (see Adapter#close) The Google client holds no persistent connection,
74
+ # so there is nothing to close; just drop the reference.
75
+ def close
76
+ @connection = nil
77
+ end
78
+
60
79
  # (see Adapter#test_connection)
61
80
  def test_connection(raise_exception: false)
62
81
  raise ConnectionError, "Dataset '#{config[:dataset]}' not found" unless connection.dataset(config[:dataset])
@@ -142,6 +161,17 @@ module DWH
142
161
 
143
162
  private
144
163
 
164
+ # Inline service-account fields win over a keyfile path. Neither present
165
+ # means Application Default Credentials.
166
+ def google_credentials
167
+ if config[:client_email].to_s != '' && config[:private_key].to_s != ''
168
+ { 'type' => 'service_account', 'project_id' => config[:project_id],
169
+ 'client_email' => config[:client_email], 'private_key' => config[:private_key] }
170
+ elsif config[:keyfile].to_s != ''
171
+ config[:keyfile]
172
+ end
173
+ end
174
+
145
175
  def dataset_name(qualifiers)
146
176
  qualifiers[:dataset] || qualifiers[:schema] || config[:dataset]
147
177
  end
data/lib/dwh/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DWH
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dwh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajo Abraham