rb_snowflake_client 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/ci.yml +5 -2
- data/.github/workflows/release-gh-packages.yml +2 -0
- data/.github/workflows/release-rubygems.yml +2 -0
- data/Gemfile +0 -6
- data/Gemfile.lock +7 -13
- data/README.md +7 -1
- data/lib/ruby_snowflake/client.rb +14 -6
- data/lib/ruby_snowflake/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e69454c7c4d16eb6f69c9ccaa67d45cbd525b61a9ade0f246fb8599c99cde89
|
4
|
+
data.tar.gz: a00b73447d1557a170f089a3e2662b8eedfa008763cb9487c4db1803581aad2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3aa6b159b79936bf28c85de07f2f13b189fc7de37c0746d151c43592a82a59d123e2023c2c776ad0d48823bf88bf96b24c3ee2d094b0c1ce64c0bd5c68ddf87
|
7
|
+
data.tar.gz: facc10e91b7bbd71df02a1f7f6158de87871f7d6e12e38e8d5e5cda8f3fce41c9487d85bb892bc7a97a63119dfe4b5595db2f3b198d73c215bcdfcf978c705a7
|
data/.github/workflows/ci.yml
CHANGED
@@ -28,10 +28,13 @@ jobs:
|
|
28
28
|
- name: Install gem
|
29
29
|
run: cd pkg && gem install --local *.gem
|
30
30
|
- name: Run tests
|
31
|
-
run:
|
31
|
+
run: bundle exec rspec
|
32
32
|
env: # Or as an environment variable
|
33
|
+
SNOWFLAKE_URI: ${{ secrets.SNOWFLAKE_URI }}
|
34
|
+
SNOWFLAKE_ORGANIZATION: ${{ secrets.SNOWFLAKE_ORGANIZATION }}
|
33
35
|
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
|
36
|
+
SNOWFLAKE_DEFAULT_WAREHOUSE: $${{ secrets.SNOWFLAKE_DEFAULT_WAREHOUSE }}
|
37
|
+
SNOWFLAKE_DEFAULT_DATABASE: ${{ secrets.SNOWFLAKE_DEFAULT_DATABASE }}
|
34
38
|
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
|
35
39
|
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
|
36
|
-
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
|
37
40
|
SNOWFLAKE_PRIVATE_KEY: ${{ secrets.SNOWFLAKE_CLIENT_TEST_PRIVATE_KEY }}
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rb_snowflake_client (1.1.
|
4
|
+
rb_snowflake_client (1.1.2)
|
5
5
|
concurrent-ruby (>= 1.2)
|
6
6
|
connection_pool (>= 2.4)
|
7
7
|
dotenv (>= 2.8)
|
@@ -15,16 +15,16 @@ GEM
|
|
15
15
|
base64 (0.2.0)
|
16
16
|
bigdecimal (3.1.8)
|
17
17
|
coderay (1.1.3)
|
18
|
-
concurrent-ruby (1.3.
|
18
|
+
concurrent-ruby (1.3.3)
|
19
19
|
connection_pool (2.4.1)
|
20
20
|
diff-lcs (1.5.1)
|
21
21
|
dotenv (3.1.2)
|
22
|
-
jwt (2.8.
|
22
|
+
jwt (2.8.2)
|
23
23
|
base64
|
24
24
|
method_source (1.1.0)
|
25
|
-
oj (3.16.
|
25
|
+
oj (3.16.4)
|
26
26
|
bigdecimal (>= 3.0)
|
27
|
-
parallel (1.
|
27
|
+
parallel (1.25.1)
|
28
28
|
pry (0.14.2)
|
29
29
|
coderay (~> 1.1)
|
30
30
|
method_source (~> 1.0)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
rspec-mocks (~> 3.13.0)
|
37
37
|
rspec-core (3.13.0)
|
38
38
|
rspec-support (~> 3.13.0)
|
39
|
-
rspec-expectations (3.13.
|
39
|
+
rspec-expectations (3.13.1)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.13.0)
|
42
42
|
rspec-mocks (3.13.1)
|
@@ -50,17 +50,11 @@ PLATFORMS
|
|
50
50
|
|
51
51
|
DEPENDENCIES
|
52
52
|
bundler
|
53
|
-
concurrent-ruby
|
54
|
-
connection_pool
|
55
|
-
dotenv
|
56
|
-
jwt
|
57
|
-
oj
|
58
53
|
parallel
|
59
54
|
pry
|
60
55
|
rake
|
61
56
|
rb_snowflake_client!
|
62
|
-
retryable
|
63
57
|
rspec
|
64
58
|
|
65
59
|
BUNDLED WITH
|
66
|
-
2.5.
|
60
|
+
2.5.10
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ The available options for connecting from Ruby to Snowflake include:
|
|
6
6
|
* ODBC - which works, but can be very slow, especially for a lot of data, which is probably why you're using Snowflake
|
7
7
|
* The [ruby snowflake client](https://github.com/rinsed-org/ruby-snowflake-client) that wraps the go client. This is probably the fastest single threaded option, which we also created. However, that library takes the ruby GVL and so stops all other processing in your ruby process (threads).
|
8
8
|
|
9
|
-
This library is implemented in ruby and while it leverages some libraries that have native extensions, doesn't currently include
|
9
|
+
This library is implemented in ruby and while it leverages some libraries that have native extensions, doesn't currently include any native extensions itself. Depending on network latency and the shape of the data this library can be faster or slower than the go wrapper. The big advantages are:
|
10
10
|
* It uses about half the memory when you pull a full result set into memory
|
11
11
|
* It does not hold onto the [ruby GVL](https://www.speedshop.co/2020/05/11/the-ruby-gvl-and-scaling.html) and so does not block other threads while waiting on IO like the go wrapper client.
|
12
12
|
* It will consume more resources for the same data, because it's using the HTTP v2 API and getting JSON back, there is just more work to as compared to the go or python clients that use Apache Arrow under the covers.
|
@@ -105,6 +105,12 @@ 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
|
+
|
108
114
|
## Binding parameters
|
109
115
|
|
110
116
|
Say we have `BIGTABLE` with a `data` column of a type `VARIANT`.
|
@@ -33,6 +33,7 @@ module RubySnowflake
|
|
33
33
|
class BadResponseError < Error ; end
|
34
34
|
class ConnectionError < Error ; end
|
35
35
|
class ConnectionStarvedError < Error ; end
|
36
|
+
class MissingConfig < Error ; end
|
36
37
|
class RetryableBadResponseError < Error ; end
|
37
38
|
class RequestError < Error ; end
|
38
39
|
class QueryTimeoutError < Error ; end
|
@@ -73,14 +74,21 @@ module RubySnowflake
|
|
73
74
|
thread_scale_factor: env_option("SNOWFLAKE_THREAD_SCALE_FACTOR", DEFAULT_THREAD_SCALE_FACTOR),
|
74
75
|
http_retries: env_option("SNOWFLAKE_HTTP_RETRIES", DEFAULT_HTTP_RETRIES),
|
75
76
|
query_timeout: env_option("SNOWFLAKE_QUERY_TIMEOUT", DEFAULT_QUERY_TIMEOUT))
|
76
|
-
private_key =
|
77
|
+
private_key =
|
78
|
+
if key = ENV["SNOWFLAKE_PRIVATE_KEY"]
|
79
|
+
key
|
80
|
+
elsif path = ENV["SNOWFLAKE_PRIVATE_KEY_PATH"]
|
81
|
+
File.read(path)
|
82
|
+
else
|
83
|
+
raise MissingConfig.new({}), "Either ENV['SNOWFLAKE_PRIVATE_KEY'] or ENV['SNOWFLAKE_PRIVATE_KEY_PATH'] must be set"
|
84
|
+
end
|
77
85
|
|
78
86
|
new(
|
79
|
-
ENV
|
87
|
+
ENV.fetch("SNOWFLAKE_URI"),
|
80
88
|
private_key,
|
81
|
-
ENV
|
82
|
-
ENV
|
83
|
-
ENV
|
89
|
+
ENV.fetch("SNOWFLAKE_ORGANIZATION"),
|
90
|
+
ENV.fetch("SNOWFLAKE_ACCOUNT"),
|
91
|
+
ENV.fetch("SNOWFLAKE_USER"),
|
84
92
|
ENV["SNOWFLAKE_DEFAULT_WAREHOUSE"],
|
85
93
|
ENV["SNOWFLAKE_DEFAULT_DATABASE"],
|
86
94
|
logger: logger,
|
@@ -223,7 +231,7 @@ module RubySnowflake
|
|
223
231
|
def retryable_http_response_code?(code)
|
224
232
|
# retry (in order): bad request, forbidden (token expired in flight), method not allowed,
|
225
233
|
# request timeout, too many requests, anything in the 500 range (504 is fairly common)
|
226
|
-
[400, 403, 405, 408, 429
|
234
|
+
[400, 403, 405, 408, 429].include?(code.to_i) || (500..599).include?(code.to_i)
|
227
235
|
end
|
228
236
|
|
229
237
|
def retryable_log_method
|
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.1.
|
4
|
+
version: 1.1.2
|
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
|
11
|
+
date: 2024-08-06 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"
|