rb_snowflake_client 1.0.6 → 1.1.1

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: af3e56d97ebae43ae931c9c50784d7a3af0fe0e4a70f7e2a28c932d30371eff5
4
- data.tar.gz: cdd2e9f55805e8d27e344925b8917b6d292aa1b07ed87ac8443060d31e224ccc
3
+ metadata.gz: '089c46288d7dc44f8717542fce8732ce32c65db796e5ac5d49fa6fff6cb1f29d'
4
+ data.tar.gz: '035589f8bcc072830f037c333379a2059eb6a205ad8ae6daecb2bb2ea9c4761a'
5
5
  SHA512:
6
- metadata.gz: 3c3aae7bf833cab432ea952419e951f51584100766eccd07d3a978c449fd1a2fd532a5756a0789242ff1baa7319dc360a162ba608d502d12436837f456033b97
7
- data.tar.gz: cf1828f9a00b3be7c6030c5bc3e6f1be834206e364be477aa944faffaaf3638dc65a61bbc215c6f7428fd103ee62a1077e9658fa08055479e632b29d15f008f7
6
+ metadata.gz: e390973b02ce165e3bb5722c84cc79cb8c1fcc8457b57ceaf9317f2675fdfe2e5b6276d7c8a496ec5605ab66c15fcdfa2247182d1f54bed39df3c8ce4240fed7
7
+ data.tar.gz: '092ba2997da8f64f6e9e7ff912d7bdb43882681f5d564028f9a9c6ad51854515e237de27b51de35329acb3fd021de3d4212551cbc31a58942592627805f2e298'
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ #
4
+ # BUNDLER
5
+ #
6
+ - package-ecosystem: bundler
7
+ directory: '/'
8
+ schedule:
9
+ interval: weekly
10
+ allow:
11
+ - dependency-type: direct
12
+ - dependency-type: indirect
13
+ open-pull-requests-limit: 10
data/Gemfile CHANGED
@@ -6,13 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "bundler"
9
- gem "concurrent-ruby"
10
- gem "connection_pool"
11
- gem "dotenv"
12
- gem "jwt"
13
- gem "oj"
14
9
  gem "rake"
15
- gem "retryable"
16
10
 
17
11
  group :development do
18
12
  gem "parallel"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rb_snowflake_client (1.0.6)
4
+ rb_snowflake_client (1.1.1)
5
5
  concurrent-ruby (>= 1.2)
6
6
  connection_pool (>= 2.4)
7
7
  dotenv (>= 2.8)
@@ -12,52 +12,49 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
+ base64 (0.2.0)
16
+ bigdecimal (3.1.8)
15
17
  coderay (1.1.3)
16
- concurrent-ruby (1.2.2)
18
+ concurrent-ruby (1.3.1)
17
19
  connection_pool (2.4.1)
18
- diff-lcs (1.5.0)
19
- dotenv (2.8.1)
20
- jwt (2.7.1)
21
- method_source (1.0.0)
22
- oj (3.16.1)
23
- parallel (1.23.0)
20
+ diff-lcs (1.5.1)
21
+ dotenv (3.1.2)
22
+ jwt (2.8.1)
23
+ base64
24
+ method_source (1.1.0)
25
+ oj (3.16.3)
26
+ bigdecimal (>= 3.0)
27
+ parallel (1.24.0)
24
28
  pry (0.14.2)
25
29
  coderay (~> 1.1)
26
30
  method_source (~> 1.0)
27
- rake (13.1.0)
31
+ rake (13.2.1)
28
32
  retryable (3.0.5)
29
- rspec (3.12.0)
30
- rspec-core (~> 3.12.0)
31
- rspec-expectations (~> 3.12.0)
32
- rspec-mocks (~> 3.12.0)
33
- rspec-core (3.12.2)
34
- rspec-support (~> 3.12.0)
35
- rspec-expectations (3.12.3)
33
+ rspec (3.13.0)
34
+ rspec-core (~> 3.13.0)
35
+ rspec-expectations (~> 3.13.0)
36
+ rspec-mocks (~> 3.13.0)
37
+ rspec-core (3.13.0)
38
+ rspec-support (~> 3.13.0)
39
+ rspec-expectations (3.13.0)
36
40
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.12.0)
38
- rspec-mocks (3.12.6)
41
+ rspec-support (~> 3.13.0)
42
+ rspec-mocks (3.13.1)
39
43
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.12.0)
41
- rspec-support (3.12.1)
44
+ rspec-support (~> 3.13.0)
45
+ rspec-support (3.13.1)
42
46
 
43
47
  PLATFORMS
44
- arm64-darwin-21
45
48
  arm64-darwin-22
46
- x86_64-linux
49
+ ruby
47
50
 
48
51
  DEPENDENCIES
49
52
  bundler
50
- concurrent-ruby
51
- connection_pool
52
- dotenv
53
- jwt
54
- oj
55
53
  parallel
56
54
  pry
57
55
  rake
58
56
  rb_snowflake_client!
59
- retryable
60
57
  rspec
61
58
 
62
59
  BUNDLED WITH
63
- 2.4.19
60
+ 2.5.4
data/README.md CHANGED
@@ -105,6 +105,30 @@ Clients are not warehouse specific, you can override the default warehouse per q
105
105
  client.query("SELECT * FROM BIGTABLE", warehouse: "FAST_WH")
106
106
  ```
107
107
 
108
+ ## Specifying a schema
109
+
110
+ ```ruby
111
+ client.query("SELECT * FROM BIGTABLE", schema: "MY_SCHEMA")
112
+ ```
113
+
114
+ ## Binding parameters
115
+
116
+ Say we have `BIGTABLE` with a `data` column of a type `VARIANT`.
117
+
118
+ ```ruby
119
+ json_string = '{"valid": "json"}'
120
+ query = "insert into BIGTABLE(data) select parse_json(?)"
121
+ bindings = {
122
+ "1": {
123
+ "type": "TEXT",
124
+ "value": json_string
125
+ }
126
+ }
127
+ client.query(query, bindings: bindings)
128
+ ```
129
+
130
+ For additional information about binding parameters refer to snowflake documentation: https://docs.snowflake.com/en/developer-guide/sql-api/submitting-requests#using-bind-variables-in-a-statement
131
+
108
132
  # Configuration Options
109
133
 
110
134
  The client supports the following configuration options, each with their own getter/setter except connection pool options which must be set at construction. Additionally, all except logger can be configured with environment variables (see above, but the pattern is like: "SNOWFLAKE_HTTP_RETRIES". Configuration options can only be set on initialization through `new` or `from_env`.
@@ -128,7 +128,7 @@ module RubySnowflake
128
128
  @_enable_polling_queries = false
129
129
  end
130
130
 
131
- def query(query, warehouse: nil, streaming: false, database: nil, schema: nil)
131
+ def query(query, warehouse: nil, streaming: false, database: nil, schema: nil, bindings: nil)
132
132
  warehouse ||= @default_warehouse
133
133
  database ||= @default_database
134
134
 
@@ -136,11 +136,11 @@ module RubySnowflake
136
136
  response = nil
137
137
  connection_pool.with do |connection|
138
138
  request_body = {
139
- "database" => database&.upcase,
139
+ "warehouse" => warehouse&.upcase,
140
140
  "schema" => schema&.upcase,
141
+ "database" => database&.upcase,
141
142
  "statement" => query,
142
- "timeout" => @query_timeout,
143
- "warehouse" => warehouse&.upcase,
143
+ "bindings" => bindings
144
144
  }
145
145
 
146
146
  response = request_with_auth_and_headers(
@@ -150,7 +150,7 @@ module RubySnowflake
150
150
  Oj.dump(request_body)
151
151
  )
152
152
  end
153
- retreive_result_set(query_start_time, query, response, streaming)
153
+ retrieve_result_set(query_start_time, query, response, streaming)
154
154
  end
155
155
 
156
156
  alias fetch query
@@ -223,7 +223,7 @@ module RubySnowflake
223
223
  def retryable_http_response_code?(code)
224
224
  # retry (in order): bad request, forbidden (token expired in flight), method not allowed,
225
225
  # request timeout, too many requests, anything in the 500 range (504 is fairly common)
226
- [400, 403, 405, 408, 429, 504].include?(code.to_i) || (500..599).include?(code)
226
+ [400, 403, 405, 408, 429, 502, 504].include?(code.to_i) || (500..599).include?(code.to_i)
227
227
  end
228
228
 
229
229
  def retryable_log_method
@@ -267,7 +267,7 @@ module RubySnowflake
267
267
  false
268
268
  end
269
269
 
270
- def retreive_result_set(query_start_time, query, response, streaming)
270
+ def retrieve_result_set(query_start_time, query, response, streaming)
271
271
  json_body = Oj.load(response.body, OJ_OPTIONS)
272
272
  statement_handle = json_body["statementHandle"]
273
273
 
@@ -277,18 +277,18 @@ module RubySnowflake
277
277
  end
278
278
 
279
279
  num_threads = number_of_threads_to_use(json_body["resultSetMetaData"]["partitionInfo"].size)
280
- retreive_proc = ->(index) { retreive_partition_data(statement_handle, index) }
280
+ retrieve_proc = ->(index) { retrieve_partition_data(statement_handle, index) }
281
281
 
282
282
  if streaming
283
- StreamingResultStrategy.result(json_body, retreive_proc)
283
+ StreamingResultStrategy.result(json_body, retrieve_proc)
284
284
  elsif num_threads == 1
285
- SingleThreadInMemoryStrategy.result(json_body, retreive_proc)
285
+ SingleThreadInMemoryStrategy.result(json_body, retrieve_proc)
286
286
  else
287
- ThreadedInMemoryStrategy.result(json_body, retreive_proc, num_threads)
287
+ ThreadedInMemoryStrategy.result(json_body, retrieve_proc, num_threads)
288
288
  end
289
289
  end
290
290
 
291
- def retreive_partition_data(statement_handle, partition_index)
291
+ def retrieve_partition_data(statement_handle, partition_index)
292
292
  partition_response = nil
293
293
  connection_pool.with do |connection|
294
294
  partition_response = request_with_auth_and_headers(
@@ -1,3 +1,3 @@
1
1
  module RubySnowflake
2
- VERSION = "1.0.6"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_snowflake_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rinsed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-05 00:00:00.000000000 Z
11
+ date: 2024-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -105,6 +105,7 @@ executables: []
105
105
  extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
+ - ".github/dependabot.yml"
108
109
  - ".github/workflows/ci.yml"
109
110
  - ".github/workflows/release-gh-packages.yml"
110
111
  - ".github/workflows/release-rubygems.yml"