rb_snowflake_client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df4fb0a8172d346a1cf606a8f5ed5333725c1459dcaefc22ae149387c052e3aa
4
- data.tar.gz: b8d9ebe83e5553aca0be2983b8b47857b447afb304147bda40da2661bca791e4
3
+ metadata.gz: 4aa627645364f92fc0e0d9ef949519a7649088e43de1e9ca7480ba284a9efba5
4
+ data.tar.gz: e18d9a6a1f297cbbb5a10aafcac9dce440c43e0ca430f0c6310c31cea28b4507
5
5
  SHA512:
6
- metadata.gz: 6f57ff1d40be759b042767cc8cb35c705f2228b638790659f0d9b238cdad9afcf8ebab389705e26bab87a89f64aba25d22feb5096f67312fd90e4712dd45142c
7
- data.tar.gz: 190ee97111afb77599e7d0e2bacdf4ab4c2d1b374bc7c0fb976e155809ab0f2f8a8e3e4d2f72df71619a468e6616de96a8a8c16db682610265ae405b05f43241
6
+ metadata.gz: 80ac86515ff08d723c5eff134ac090b60c079695da9c68cf39b06f8db5d1661f700b78930f5da2c19b3f4686563d4dbcda47df70f9ad35200af9e7582b09ea8b
7
+ data.tar.gz: d4c10ff8bba434ccd0ee380bbaaf9d14bfc7aed22543c34397fd6e1f83611daab65efeacf8caf241a98fd5e2a0f3591592b47f7c76de4997cfe2ea2fb951a5b8
data/Gemfile.lock CHANGED
@@ -1,7 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rb_snowflake_client (0.1.1)
4
+ rb_snowflake_client (0.1.2)
5
+ concurrent-ruby (>= 1.2)
6
+ connection_pool (>= 2.4)
7
+ dotenv (>= 2.8)
8
+ jwt (>= 2.7)
9
+ oj (>= 3.16)
10
+ retryable (>= 3.0)
5
11
 
6
12
  GEM
7
13
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -32,6 +32,7 @@ client = RubySnowflake::Client.new(
32
32
  "snowflake-account", # typically your subdomain
33
33
  "snowflake-user", # Your snowflake user
34
34
  "some_warehouse", # The name of your warehouse to use by default
35
+ "some_database", # The name of the database in the context of which the queries will run
35
36
  max_connections: 12, # Config options can be passed in
36
37
  connection_timeout: 45, # See below for the full set of options
37
38
  )
@@ -48,6 +49,7 @@ Available ENV variables (see below in the config section for details)
48
49
  `SNOWFLAKE_ACCOUNT`
49
50
  `SNOWFLAKE_USER`
50
51
  `SNOWFLAKE_DEFAULT_WAREHOUSE`
52
+ `SNOWFLAKE_DEFAULT_DATABASE`
51
53
  `SNOWFLAKE_JWT_TOKEN_TTL`
52
54
  `SNOWFLAKE_CONNECTION_TIMEOUT`
53
55
  `SNOWFLAKE_MAX_CONNECTIONS`
@@ -75,6 +77,14 @@ result = client.query("SELECT * FROM HUGETABLE", streaming: true)
75
77
  result.each do |row|
76
78
  puts row
77
79
  end
80
+
81
+
82
+ # You can also overwrite the database specified in the initializer, and run
83
+ # your query with a different context.
84
+ result = client.query("SELECT * FROM SECRET_TABLE", database: "OTHER_DB")
85
+ result.each do |row|
86
+ puts row
87
+ end
78
88
  ```
79
89
 
80
90
  # Configuration Options
@@ -97,6 +107,7 @@ Example configuration:
97
107
  client.max_connections = 24
98
108
  client.http_retries = 1
99
109
  end
110
+ ```
100
111
 
101
112
  # Gotchas
102
113
 
@@ -153,6 +164,7 @@ client = RubySnowflake::Client.new(
153
164
  "snowflake-account", # typically your subdomain
154
165
  "snowflake-user", # Your snowflake user
155
166
  "some_warehouse", # The name of your warehouse to use by default
167
+ "some_database", # The name of the database in the context of which the queries will run
156
168
  )
157
169
  ```
158
170
 
@@ -69,6 +69,7 @@ module RubySnowflake
69
69
  ENV["SNOWFLAKE_ACCOUNT"],
70
70
  ENV["SNOWFLAKE_USER"],
71
71
  ENV["SNOWFLAKE_DEFAULT_WAREHOUSE"],
72
+ ENV["SNOWFLAKE_DEFAULT_DATABASE"],
72
73
  jwt_token_ttl: env_option("SNOWFLAKE_JWT_TOKEN_TTL", DEFAULT_JWT_TOKEN_TTL),
73
74
  connection_timeout: env_option("SNOWFLAKE_CONNECTION_TIMEOUT", DEFAULT_CONNECTION_TIMEOUT ),
74
75
  max_connections: env_option("SNOWFLAKE_MAX_CONNECTIONS", DEFAULT_MAX_CONNECTIONS ),
@@ -78,15 +79,17 @@ module RubySnowflake
78
79
  )
79
80
  end
80
81
 
81
- def initialize(uri, private_key, organization, account, user, default_warehouse,
82
- logger: DEFAULT_LOGGER,
83
- log_level: DEFAULT_LOG_LEVEL,
84
- jwt_token_ttl: DEFAULT_JWT_TOKEN_TTL,
85
- connection_timeout: DEFAULT_CONNECTION_TIMEOUT,
86
- max_connections: DEFAULT_MAX_CONNECTIONS,
87
- max_threads_per_query: DEFAULT_MAX_THREADS_PER_QUERY,
88
- thread_scale_factor: DEFAULT_THREAD_SCALE_FACTOR,
89
- http_retries: DEFAULT_HTTP_RETRIES)
82
+ def initialize(
83
+ uri, private_key, organization, account, user, default_warehouse, default_database,
84
+ logger: DEFAULT_LOGGER,
85
+ log_level: DEFAULT_LOG_LEVEL,
86
+ jwt_token_ttl: DEFAULT_JWT_TOKEN_TTL,
87
+ connection_timeout: DEFAULT_CONNECTION_TIMEOUT,
88
+ max_connections: DEFAULT_MAX_CONNECTIONS,
89
+ max_threads_per_query: DEFAULT_MAX_THREADS_PER_QUERY,
90
+ thread_scale_factor: DEFAULT_THREAD_SCALE_FACTOR,
91
+ http_retries: DEFAULT_HTTP_RETRIES
92
+ )
90
93
  @base_uri = uri
91
94
  @private_key_pem = private_key
92
95
  @organization = organization
@@ -94,6 +97,7 @@ module RubySnowflake
94
97
  @user = user
95
98
  @default_warehouse = default_warehouse
96
99
  @public_key_fingerprint = public_key_fingerprint(@private_key_pem)
100
+ @default_database = default_database
97
101
 
98
102
  # set defaults for config settings
99
103
  @logger = logger
@@ -110,12 +114,15 @@ module RubySnowflake
110
114
  @token_semaphore = Concurrent::Semaphore.new(1)
111
115
  end
112
116
 
113
- def query(query, warehouse: nil, streaming: false)
117
+ def query(query, warehouse: nil, streaming: false, database: nil)
114
118
  warehouse ||= @default_warehouse
119
+ database ||= @default_database
115
120
 
116
121
  response = nil
117
122
  connection_pool.with do |connection|
118
- request_body = { "statement" => query, "warehouse" => warehouse }
123
+ request_body = {
124
+ "statement" => query, "warehouse" => warehouse, "database" => database
125
+ }
119
126
 
120
127
  response = request_with_auth_and_headers(
121
128
  connection,
@@ -1,3 +1,3 @@
1
1
  module RubySnowflake
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -18,4 +18,10 @@ Gem::Specification.new do |s|
18
18
  end
19
19
 
20
20
  s.require_paths = ["lib"]
21
+ s.add_dependency "concurrent-ruby", ">= 1.2"
22
+ s.add_dependency "connection_pool", ">= 2.4"
23
+ s.add_dependency "dotenv", ">= 2.8"
24
+ s.add_dependency "jwt", ">= 2.7"
25
+ s.add_dependency "oj", ">= 3.16"
26
+ s.add_dependency "retryable", ">= 3.0"
21
27
  end
metadata CHANGED
@@ -1,15 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_snowflake_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.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: 2023-12-01 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: concurrent-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: connection_pool
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jwt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: oj
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3.16'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '3.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: retryable
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
13
97
  description: 'Using the HTTP V2 Api for Snowflake runs queries & creates native Ruby
14
98
  objects.
15
99