rb_snowflake_client 1.0.6 → 1.1.0

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: 7c61238d7915a65cc04b0219e1fd8dc016cc645d8b62819264e2476cd22bdace
4
+ data.tar.gz: b23ace47b825ed4650a12c1fe51b88a72ee51e9e6451e8421c99efbad14ccd1f
5
5
  SHA512:
6
- metadata.gz: 3c3aae7bf833cab432ea952419e951f51584100766eccd07d3a978c449fd1a2fd532a5756a0789242ff1baa7319dc360a162ba608d502d12436837f456033b97
7
- data.tar.gz: cf1828f9a00b3be7c6030c5bc3e6f1be834206e364be477aa944faffaaf3638dc65a61bbc215c6f7428fd103ee62a1077e9658fa08055479e632b29d15f008f7
6
+ metadata.gz: 9c6616faa6d200731c4783e2ae0390022b9a90086e05e9c8b19527e74b65c59912155240f036f660c83c24b50fa30242a14a79f4b4c6b464cdc2d51a396725cf
7
+ data.tar.gz: 3dfeceb361c57f2f40eb3e3adc626abd0832ee977ef8ed86cdd089ae4f1eae95013c8441085aa3c9e74b19f8f367f7259adc75a477ecc34dcffeddbc65853158
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.0)
5
5
  concurrent-ruby (>= 1.2)
6
6
  connection_pool (>= 2.4)
7
7
  dotenv (>= 2.8)
@@ -12,38 +12,41 @@ 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
@@ -60,4 +63,4 @@ DEPENDENCIES
60
63
  rspec
61
64
 
62
65
  BUNDLED WITH
63
- 2.4.19
66
+ 2.5.4
data/README.md CHANGED
@@ -105,6 +105,24 @@ 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
+ ## Binding parameters
109
+
110
+ Say we have `BIGTABLE` with a `data` column of a type `VARIANT`.
111
+
112
+ ```ruby
113
+ json_string = '{"valid": "json"}'
114
+ query = "insert into BIGTABLE(data) select parse_json(?)"
115
+ bindings = {
116
+ "1": {
117
+ "type": "TEXT",
118
+ "value": json_string
119
+ }
120
+ }
121
+ client.query(query, bindings: bindings)
122
+ ```
123
+
124
+ 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
125
+
108
126
  # Configuration Options
109
127
 
110
128
  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
@@ -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.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rinsed