dbx-api 0.2.0 → 0.3.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: '09cd7a1984478b2761fbe0dca4b69acd123d664c96ea7333997143fe4389aa3b'
4
- data.tar.gz: 5e1093ab32b19c13eff195869d12dc159459f4418f3bc260df241e737cd5f78f
3
+ metadata.gz: 94d4b8f9d3d55224b5c93191aab3aefe280457e30ade7fba3b0f515cf0556991
4
+ data.tar.gz: ff70dbe1f9e6b1449449adb986616a77f6e682a150b21e07f4476c1f138b43d8
5
5
  SHA512:
6
- metadata.gz: 407516bedbe4fa69d01ad765804aa2593966faebfa966eadac4ed08da44fb41fc7ea055b2be781194e762916784c4cb1d0bb0d4c44b9b3ad8ed23273415277f2
7
- data.tar.gz: 569cdbc0465214559dd397e27d143cf3e56fbc96e1f1447c45bd18ba472ef444ec712cf16ae69837b6380de54135c3e42dd1af775f22221954b149c70f249a5c
6
+ metadata.gz: 90e01075d9a1bd9f5a138ee65709a55ec476f24d8f59ae4e4ff0570e381235fd04538df89cab93a3350fa9a6f449e4c6e7033ef518cf447ec23cd5bc772bce1d
7
+ data.tar.gz: 6463504efcf34b1024066249b0e0f558667df0e1448a8c5e5891b1f8f84b0006657e7b21a298880ad7d66d2ca4c0d8e1f38e3aab9ba4c57ec8bd4179b378f2fd
data/CHANGELOG.md CHANGED
@@ -11,4 +11,12 @@
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
18
+
19
+ ## [0.3.0]
20
+ - Update Readme
21
+ - Remove `allowed_host` to allow pushing to multiple hosts
22
+ - Update Gemfile to add dev and test groups
data/Gemfile CHANGED
@@ -5,8 +5,15 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in dbx.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ group :development do
9
+ gem "rake", "~> 13.0"
10
+ gem "rubocop", "~> 1.21"
11
+ end
9
12
 
10
- gem "rspec", "~> 3.0"
13
+ group :test do
14
+ gem "rspec", "~> 3.0"
15
+ end
11
16
 
12
- gem "rubocop", "~> 1.21"
17
+ group :development, :test do
18
+ gem "pry"
19
+ end
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.3.0)
5
5
  dotenv (~> 2.0)
6
6
 
7
7
  GEM
@@ -9,14 +9,19 @@ GEM
9
9
  specs:
10
10
  ast (2.4.2)
11
11
  base64 (0.1.1)
12
+ coderay (1.1.3)
12
13
  diff-lcs (1.5.0)
13
14
  dotenv (2.8.1)
14
15
  json (2.6.3)
15
16
  language_server-protocol (3.17.0.3)
17
+ method_source (1.1.0)
16
18
  parallel (1.23.0)
17
19
  parser (3.2.2.3)
18
20
  ast (~> 2.4.1)
19
21
  racc
22
+ pry (0.15.2)
23
+ coderay (~> 1.1)
24
+ method_source (~> 1.0)
20
25
  racc (1.7.1)
21
26
  rainbow (3.1.1)
22
27
  rake (13.0.6)
@@ -54,9 +59,11 @@ GEM
54
59
 
55
60
  PLATFORMS
56
61
  arm64-darwin-22
62
+ arm64-darwin-24
57
63
 
58
64
  DEPENDENCIES
59
65
  dbx-api!
66
+ pry
60
67
  rake (~> 13.0)
61
68
  rspec (~> 3.0)
62
69
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -6,7 +6,7 @@ This gem is designed to allow access to the DBX APIs (Jobs and SQL) from ruby ap
6
6
  ## Installation
7
7
  Add the following to your Gemfile to install
8
8
  ```ruby
9
- gem 'dbx-api', '~>0.2.0'
9
+ gem 'dbx-api', '~>0.2.1'
10
10
  ```
11
11
 
12
12
  ## Usage
@@ -80,17 +80,38 @@ 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.
91
110
  - Run `rake spec` to run the rspec tests.
92
111
 
93
112
  ## Build
94
- - Run `gem build dbx.gemspec ` to build the gem.
95
- - 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`
113
+ - Run `gem build dbx.gemspec` to build the gem.
114
+ - To push to RubyGems.org:
115
+ - Run `gem push dbx-api-[VERSION].gem` (requires logging in to rubygems.org first via `gem login`)
116
+ - To push to Artifactory:
117
+ - Run `gem push dbx-api-[VERSION].gem --host https://artifactory.wu2.cloud.providence.org/artifactory/api/gems/mgl-ruby-virtual`
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pry"
4
-
5
3
  # This class represents a response from the Databricks SQL API.
6
4
  # It is used by DatabricksSQL to handle http failures and parse the response body.
7
5
  class DatabricksSQLResponse
@@ -97,15 +95,16 @@ class DatabricksSQLResponse
97
95
  body.dig("result", "data_array") || body["data_array"] || []
98
96
  end
99
97
 
100
- # Return the results of the query as an array of hashes.
98
+ # Return the results of the query as an array of hashes with string keys.
101
99
  # @return [Array<Hash>]
102
- def results
100
+ def results(symbolize_keys: false)
103
101
  return [] if failed?
104
102
 
105
103
  data_array.map do |row|
106
104
  hash = {}
107
105
  columns.each do |column|
108
- hash[column["name"]] = row[column["position"]]
106
+ key = symbolize_keys ? column["name"].to_sym : column["name"]
107
+ hash[key] = row[column["position"]]
109
108
  end
110
109
  hash
111
110
  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.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
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.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - cmmille
8
- autorequire:
7
+ - Christopher Lockfeld
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: dotenv
@@ -49,14 +48,14 @@ files:
49
48
  - lib/dbx/gateway.rb
50
49
  - lib/dbx/version.rb
51
50
  - sig/dbx.rbs
52
- homepage: https://github.com/pdxmolab/dbx-gem
51
+ homepage: https://github.com/PSJH/mgl-dbx-gem
53
52
  licenses:
54
53
  - MIT
55
54
  metadata:
56
- homepage_uri: https://github.com/pdxmolab/dbx-gem
57
- source_code_uri: https://github.com/pdxmolab/dbx-gem
58
- changelog_uri: https://github.com/pdxmolab/dbx-gem/blob/main/CHANGELOG.md
59
- post_install_message:
55
+ homepage_uri: https://github.com/PSJH/mgl-dbx-gem
56
+ source_code_uri: https://github.com/PSJH/mgl-dbx-gem
57
+ changelog_uri: https://github.com/PSJH/mgl-dbx-gem/blob/main/CHANGELOG.md
58
+ rubygems_mfa_required: 'true'
60
59
  rdoc_options: []
61
60
  require_paths:
62
61
  - lib
@@ -71,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
70
  - !ruby/object:Gem::Version
72
71
  version: '0'
73
72
  requirements: []
74
- rubygems_version: 3.4.6
75
- signing_key:
73
+ rubygems_version: 3.6.7
76
74
  specification_version: 4
77
75
  summary: Access the Databricks API with ruby.
78
76
  test_files: []