snowflake_rb 0.0.0 → 0.0.2

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: f52d1d74097341acc40cf111a11d5ab1bf403eb59e14dbf0405b78fa4a51d067
4
- data.tar.gz: e1fde37704e432fb3ec95825b51c57490e8535f303a9891ece31bc0545187feb
3
+ metadata.gz: 0a94c064ba5cf498085fca7c2138d08b352f83b3a94a2a1f7465fb3f9de13c50
4
+ data.tar.gz: b5772f5dfa28f418a50dbdd60d579fdab0e0eb43d34c8e88e9e20d88fc9be923
5
5
  SHA512:
6
- metadata.gz: 81351cbcddcedc5228d22689e7d6bce667a57cf4640e50286da04c91c6feaa00f5c2747d3cc3264ef1238c8f0270045232c9c03d53d70ff16da958bdf3c62ba7
7
- data.tar.gz: cfba487d85753ae881613ff6daf91c0d0713d409d93f8f09eb0f45e46258709152a0f360d0efb5f15d39aa0b3548e503f92dba1df34b79b18108167f90d878cd
6
+ metadata.gz: 51abadd71833419043c7d569c22e9a6be05191db4dcfa3a014bf2b8ccf480bb43ec6c8637e518d8def995bd9a334afb6263219cc6c5c7e0e24134d4677a32052
7
+ data.tar.gz: b1cf22485fc54d7d47f26e6a5e0980f089024325a84a8e54cad86c829e7f7978b047482112b818d6dd253c0007e3e80a888f6b73c916db3874eb09b7e36a8ef3
Binary file
Binary file
Binary file
data/ext/snowflake.so CHANGED
Binary file
@@ -1,18 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-configurable'
4
-
5
3
  module SnowflakeRB
6
- module Configuration
7
- extend Dry::Configurable
4
+ # Configuration class for snowflake_rb
5
+ # config = Configuration.new
6
+ # config.account = <ACCOUNT>
7
+ # config.warehouse = <WAREHOUSE>
8
+ # config.database = <DATABASE>
9
+ # config.schema = <SCHEMA>
10
+ # config.user = <USER>
11
+ # config.password = <PASSWORD>
12
+ # config.role = <ROLE>
13
+ class Configuration
14
+ attr_accessor :account, :warehouse, :database, :schema, :user, :password, :role
15
+ attr_writer :port
8
16
 
9
- setting :account
10
- setting :warehouse
11
- setting :database
12
- setting :schema
13
- setting :user
14
- setting :password
15
- setting :role
16
- setting :port, default: 443
17
+ def port
18
+ @port || 443
19
+ end
17
20
  end
18
- end
21
+ end
data/lib/snowflake_rb.rb CHANGED
@@ -2,9 +2,6 @@ require 'ffi'
2
2
  require 'snowflake_rb/extension'
3
3
  require 'snowflake_rb/configuration'
4
4
 
5
- # Note: this library is not thread safe as it caches the last error
6
- # The call pattern expectation is to call last_error after any call which may have gotten an error. If last_error is
7
- # `nil`, there was no error.
8
5
  module Snowflake
9
6
  module LibC
10
7
  extend FFI::Library
@@ -19,7 +16,6 @@ module Snowflake
19
16
  POINTER_SIZE = FFI.type_size(:pointer)
20
17
 
21
18
  ffi_lib(File.expand_path(SnowflakeRB::Extension.env_specific_extension_path, __dir__))
22
- attach_function(:last_error, 'LastError', [], :strptr)
23
19
  # ugh, `port` in gosnowflake is just :int; however, ruby - ffi -> go is passing 32bit int if I just decl :int.
24
20
  attach_function(:connect, 'Connect', %i[string string string string string string string int64], :pointer)
25
21
  attach_function(:close, 'Close', [:pointer], :void)
@@ -31,16 +27,8 @@ module Snowflake
31
27
  end
32
28
 
33
29
  module Client
34
- extend SnowflakeRB::Configuration
35
30
  module_function
36
31
 
37
- # @return String last error or nil. May be end of file which is not really an error
38
- def last_error
39
- error, cptr = ::Snowflake::Binding.last_error
40
- LibC.free(cptr) if error
41
- error
42
- end
43
-
44
32
  # @param account[String] should include everything in the db url ahead of 'snowflakecomputing.com'
45
33
  # @param port[Integer]
46
34
  # @return query_object[Pointer] a pointer to use for subsequent calls not inspectable nor viewable by Ruby
@@ -55,14 +43,14 @@ module Snowflake
55
43
  port = nil
56
44
  )
57
45
  ::Snowflake::Binding.connect(
58
- account || config.account,
59
- warehouse || config.warehouse,
60
- database || config.database,
61
- schema || config.schema,
62
- user || config.user,
63
- password || config.password,
64
- role || config.role,
65
- port || config.port
46
+ account || Snowflake::configuration.account,
47
+ warehouse || Snowflake::configuration.warehouse,
48
+ database || Snowflake::configuration.database,
49
+ schema || Snowflake::configuration.schema,
50
+ user || Snowflake::configuration.user,
51
+ password || Snowflake::configuration.password,
52
+ role || Snowflake::configuration.role,
53
+ port || Snowflake::configuration.port
66
54
  )
67
55
  end
68
56
 
@@ -89,12 +77,12 @@ module Snowflake
89
77
  return to_enum(__method__, db_pointer, sql) unless block_given?
90
78
 
91
79
  query_pointer = fetch(db_pointer, sql)
92
- return last_error if query_pointer.nil? || query_pointer == FFI::Pointer::NULL
80
+ return 'query_pointer is missing' if query_pointer.nil? || query_pointer == FFI::Pointer::NULL
93
81
 
94
82
  field_count ||= column_count(query_pointer)
95
83
  loop do
96
84
  row = get_next_row(query_pointer, field_count)
97
- return last_error unless row
85
+ return 'row not present' unless row
98
86
 
99
87
  yield row
100
88
  end
@@ -104,7 +92,6 @@ module Snowflake
104
92
  # @param db_pointer[Pointer] the pointer which `connect` returned.
105
93
  # @param query[String] a select query to run.
106
94
  # @return query_object[Pointer] a pointer to use for subsequent calls not inspectable nor viewable by Ruby; however,
107
- # if it's `nil`, check `last_error`
108
95
  def fetch(db_pointer, query)
109
96
  ::Snowflake::Binding.fetch(db_pointer, query)
110
97
  end
@@ -161,4 +148,14 @@ module Snowflake
161
148
  SnowflakeRB::Configuration.config
162
149
  end
163
150
  end
151
+
152
+ class << self
153
+ def configuration
154
+ @configuration ||= SnowflakeRB::Configuration.new
155
+ end
156
+
157
+ def configure
158
+ yield(configuration)
159
+ end
160
+ end
164
161
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snowflake_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cheng
8
8
  - Arjun Krishnan
9
- - Mohammad-Reza
9
+ - Mohammad-Reza Daliri
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-04-12 00:00:00.000000000 Z
13
+ date: 2023-05-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -26,20 +26,6 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: 1.15.5
29
- - !ruby/object:Gem::Dependency
30
- name: dry-configurable
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: 1.0.1
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: 1.0.1
43
29
  description: This gem adds a ruby wrapper around the go native snowflake client
44
30
  email:
45
31
  - darren@thanx.com