dbx-api 0.2.0 → 0.2.1

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: '09cd7a1984478b2761fbe0dca4b69acd123d664c96ea7333997143fe4389aa3b'
4
- data.tar.gz: 5e1093ab32b19c13eff195869d12dc159459f4418f3bc260df241e737cd5f78f
3
+ metadata.gz: c868f357a1e4f6659b248d71be4567ddce7b4e2b0099a094b3cf473c5100b5ff
4
+ data.tar.gz: ec6d7f7a72ce00d9a21396f506f7b7a8f7795f072c5d7541a5b96d1710bc2b5a
5
5
  SHA512:
6
- metadata.gz: 407516bedbe4fa69d01ad765804aa2593966faebfa966eadac4ed08da44fb41fc7ea055b2be781194e762916784c4cb1d0bb0d4c44b9b3ad8ed23273415277f2
7
- data.tar.gz: 569cdbc0465214559dd397e27d143cf3e56fbc96e1f1447c45bd18ba472ef444ec712cf16ae69837b6380de54135c3e42dd1af775f22221954b149c70f249a5c
6
+ metadata.gz: 354a655157aad1118192f0d01d93db0844d861e6277cb53af0befe1f1d8e3318bfec296d512b7c6ac07650fb1ea7ff26e8a4235a61e4d3457e9395ea65e59fd6
7
+ data.tar.gz: 3c9ae8e759f56d5f8d3e0c38f2cfbbdee4b237dc36ca6436924ad60b7384957e9f7e4a1f7239873234f96e87af21b00a08f6de1ad629ec5b013c2fbe1e6d2241
data/CHANGELOG.md CHANGED
@@ -11,4 +11,7 @@
11
11
  - `DatabricksGateway::run_sql` now returns an object of type `DatabricksSQLResponse`
12
12
  - results can be accessed by `DatabricksSQLResponse::results`
13
13
  - query success can be accessed by `DatabricksSQLResponse::success?`
14
- - Added optional `sleep_timer` parameter to `DatabricksGateway`. This is the number of seconds to wait between checking the status of a query. Defaults to 5 seconds.
14
+ - Added optional `sleep_timer` parameter to `DatabricksGateway`. This is the number of seconds to wait between checking the status of a query. Defaults to 5 seconds.
15
+
16
+ ## [0.2.1]
17
+ - Added option to `DatabricksSQLResponse::results` to return symbolized keys
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbx-api (0.2.0)
4
+ dbx-api (0.2.1)
5
5
  dotenv (~> 2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -80,11 +80,30 @@ return res.results if res.success?
80
80
  puts "query failed: #{res.error_message}"
81
81
  ```
82
82
 
83
+ The result of `DatabrucksSQLResponse.results` is always a an array of hashes with string keys. You can map over this array using whatever ruby code you like. For example:
84
+ ```ruby
85
+ sql_response = sql_runnner.run_sql(my_query)
86
+
87
+ # count the number of results
88
+ sql_response.results.length
89
+ ```
90
+
91
+ If you would prefer a symbolized hash, you can use the `symbolize_keys` option when calling `results`:
92
+ ```ruby
93
+ sql_response.results(symbolize_keys: true)
94
+ ```
95
+
83
96
  Since `run_sql` returns an instance of `DatabricksSQLResponse`, you can also chain methods together:
84
97
  ```ruby
85
98
  sql_runner.run_sql("SELECT 1").results
86
99
  ```
87
100
 
101
+ The `run_sql` method hanldes slow queries by pinging databricks at set time intervals (default 5 seconds) until the query either fails or succeeds. The default sleep_timer can be set to any desired time interval at initialization:
102
+ ```ruby
103
+ # changing the default sleep timer to 1 second
104
+ sql_runner = DatabricksGateway.new(sleep_timer: 1)
105
+ ```
106
+
88
107
  ## Development
89
108
  - After checking out the repo, run `bin/setup` to install dependencies.
90
109
  - Set up your `.env` file as described above.
@@ -93,4 +112,4 @@ sql_runner.run_sql("SELECT 1").results
93
112
  ## Build
94
113
  - Run `gem build dbx.gemspec ` to build the gem.
95
114
  - Run `gem push dbx-api-0.2.0.gem` to push the gem to rubygems.org
96
- - Requires logging in to rubygems.org first via `gem login`
115
+ - Requires logging in to rubygems.org first via `gem login`
@@ -97,15 +97,16 @@ class DatabricksSQLResponse
97
97
  body.dig("result", "data_array") || body["data_array"] || []
98
98
  end
99
99
 
100
- # Return the results of the query as an array of hashes.
100
+ # Return the results of the query as an array of hashes with string keys.
101
101
  # @return [Array<Hash>]
102
- def results
102
+ def results(symbolize_keys: false)
103
103
  return [] if failed?
104
104
 
105
105
  data_array.map do |row|
106
106
  hash = {}
107
107
  columns.each do |column|
108
- hash[column["name"]] = row[column["position"]]
108
+ key = symbolize_keys ? column["name"].to_sym : column["name"]
109
+ hash[key] = row[column["position"]]
109
110
  end
110
111
  hash
111
112
  end
data/lib/dbx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dbx
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbx-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cmmille
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -56,6 +56,7 @@ metadata:
56
56
  homepage_uri: https://github.com/pdxmolab/dbx-gem
57
57
  source_code_uri: https://github.com/pdxmolab/dbx-gem
58
58
  changelog_uri: https://github.com/pdxmolab/dbx-gem/blob/main/CHANGELOG.md
59
+ rubygems_mfa_required: 'true'
59
60
  post_install_message:
60
61
  rdoc_options: []
61
62
  require_paths: