athens 0.3.6 → 0.4.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: dce70371a1505fb7f63bfbcd872ba136b998b146b005e084ae7d4f3bf5394c7b
4
- data.tar.gz: 69e24000860943707e5b52f24dbb2289e76e0dd35c970ca9f50a59aab07289cd
3
+ metadata.gz: cb4922b50ef935d722a54d54d4f3d9a9e47b587b67592454b806bf11e00f7be1
4
+ data.tar.gz: 2fc14349880958e3212444e8285a0005c76f9e1bcb219ac8423cb1f1cdacfb57
5
5
  SHA512:
6
- metadata.gz: e7b59f65553704094baf50bb4d609bacb2ec698f788ff89f27a679e9663418aa3c08282dbcd9a5a65c42a9b15065a74a2b35af111900b0965af103ef5538e29c
7
- data.tar.gz: 62c44387712ce5bdc94da5f4091b676d7ef6e4a330ddd90732bc92f6e64cfb61a8078f93e3aaf930be04fc1e952a0c827cb4177c3c6226c37eedcbfee21b7aca
6
+ metadata.gz: 6c8dc6d78814f5b947d08434b8f2ccf13998439fca59465495401cc9e73f7e7e30efe3899679d545fe17184704b81fab33ddf5ffc5d2eb833e6ea2ef67dc6f2e
7
+ data.tar.gz: 4e7d3d6f0cd1bdd5da7644c16b8802bc810d8f15f12e05fcd746acb743d48fe5c0ff740928ae117047aa2d6c2417daf33b86cab630cfbe0f42e87650c58e7909
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## 0.4.0 / 2021-12-03
2
+
3
+ * Added automatic parsing of JSON columns (thanks [darkside](https://github.com/darkside))
4
+
5
+ #### Potentially breaking change
6
+
7
+ If you were previously querying JSON type data and parsing it from a string in your own code, you'll want to remove that before upgrading.
8
+
9
+ For example, with previous versions you could do this (even though it would generate a warning):
10
+
11
+ ```ruby
12
+ > query = conn.execute("SELECT JSON_PARSE('{\"a\": 1, \"b\": 2}');")
13
+ > query.wait
14
+ > JSON.parse(query.to_a(header_row: false).first[0])
15
+ WARNING: Unsupported type: json, defaulting to string
16
+ => {"a"=>1, "b"=>2}
17
+ ```
18
+
19
+ After upgrading, that same code will give you an error:
20
+ ```ruby
21
+ > JSON.parse(query.to_a(header_row: false).first[0])
22
+ Traceback (most recent call last):
23
+ 5: from bin/console:14:in `<main>'
24
+ 4: from (irb):12:in `<main>'
25
+ 3: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `parse'
26
+ 2: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `new'
27
+ 1: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `initialize'
28
+ TypeError (no implicit conversion of Hash into String)
29
+ ```
30
+
31
+ Instead just remove your json parsing since Athens handles it now:
32
+ ```ruby
33
+ > query = conn.execute("SELECT JSON_PARSE('{\"a\": 1, \"b\": 2}');")
34
+ > query.wait
35
+ > query.to_a(header_row: false).first[0]
36
+ => {:a=>1, :b=>2}
37
+ ```
38
+
39
+
1
40
  ## 0.3.6 / 2021-11-16
2
41
 
3
42
  * Addition of :result_encryption as a configuration option to change encryption options for query results (https://github.com/getletterpress/athens/issues/12)
data/Gemfile.lock CHANGED
@@ -1,18 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- athens (0.3.6)
4
+ athens (0.4.0)
5
5
  aws-sdk-athena (~> 1)
6
+ multi_json (~> 1.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  aws-eventstream (1.2.0)
11
- aws-partitions (1.530.0)
12
- aws-sdk-athena (1.43.0)
12
+ aws-partitions (1.539.0)
13
+ aws-sdk-athena (1.44.0)
13
14
  aws-sdk-core (~> 3, >= 3.122.0)
14
15
  aws-sigv4 (~> 1.1)
15
- aws-sdk-core (3.122.1)
16
+ aws-sdk-core (3.124.0)
16
17
  aws-eventstream (~> 1, >= 1.0.2)
17
18
  aws-partitions (~> 1, >= 1.525.0)
18
19
  aws-sigv4 (~> 1.1)
@@ -20,6 +21,7 @@ GEM
20
21
  aws-sigv4 (1.4.0)
21
22
  aws-eventstream (~> 1, >= 1.0.2)
22
23
  jmespath (1.4.0)
24
+ multi_json (1.15.0)
23
25
  rake (13.0.6)
24
26
  rexml (3.2.5)
25
27
 
data/Vagrantfile CHANGED
@@ -4,13 +4,11 @@
4
4
  # Provisioning script
5
5
  $script = <<SCRIPT
6
6
  echo "*** Updating packages"
7
-
8
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -y aptitude
9
- sudo DEBIAN_FRONTEND=noninteractive aptitude update
10
- sudo DEBIAN_FRONTEND=noninteractive aptitude -y safe-upgrade
7
+ sudo DEBIAN_FRONTEND=noninteractive apt-get update
8
+ sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade
11
9
 
12
10
  echo "*** Installing new packages"
13
- sudo DEBIAN_FRONTEND=noninteractive aptitude install -y curl git-core vim
11
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl git-core vim
14
12
 
15
13
  if rvm -v 2>/dev/null; then
16
14
  echo "*** rvm already installed, skipping"
@@ -30,7 +28,7 @@ SCRIPT
30
28
 
31
29
 
32
30
  Vagrant.configure('2') do |config|
33
- config.vm.box = "ubuntu/xenial64"
31
+ config.vm.box = "ubuntu/focal64"
34
32
  config.vm.hostname = 'athens-dev'
35
33
 
36
34
  # Provision the machine with the shell script above
data/athens.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.required_ruby_version = '>= 2.4'
36
36
 
37
37
  spec.add_dependency "aws-sdk-athena", "~> 1"
38
+ spec.add_dependency 'multi_json', '~> 1.0'
38
39
 
39
40
  spec.add_development_dependency "bundler", ">= 1.17"
40
41
  spec.add_development_dependency "rake", "~> 13.0"
data/lib/athens/query.rb CHANGED
@@ -141,7 +141,7 @@ module Athens
141
141
  metadata.column_info.each_with_index do |col, index|
142
142
  data = row.data[index].var_char_value
143
143
  nullable = ["UNKNOWN", "NULLABLE"].include?(col.nullable)
144
-
144
+
145
145
  if nullable && data.nil?
146
146
  mapped << data
147
147
  elsif !nullable && data.nil?
@@ -166,6 +166,8 @@ module Athens
166
166
  mapped << Date.parse(data)
167
167
  when 'boolean'
168
168
  mapped << (data == "true")
169
+ when 'json'
170
+ mapped << MultiJson.load(data, symbolize_keys: true)
169
171
  else
170
172
  puts "WARNING: Unsupported type: #{col.type}, defaulting to string"
171
173
  mapped << data
@@ -1,3 +1,3 @@
1
1
  module Athens
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/athens.rb CHANGED
@@ -5,6 +5,7 @@ require "athens/connection"
5
5
  require "athens/query"
6
6
 
7
7
  require 'aws-sdk-athena'
8
+ require 'multi_json'
8
9
 
9
10
  module Athens
10
11
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schulte
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2021-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-athena
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement