athens 0.3.5 → 0.4.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: b0751e4a11947a14a576b1a2b251c53af99a90b7b88e15617f810767efb3cce9
4
- data.tar.gz: a6dbc5ef43c672a80df58c68159614c02a25a4b377039111d68ac104d9712473
3
+ metadata.gz: 4bed77ded41e5ac8bcff35169ac9fec6ffe6f2b9732aefe05c8e1fb034a0afc5
4
+ data.tar.gz: 1b0c5f99c343e0179a81a92b115725542704bff8a1f50884a41b48d7fd557be3
5
5
  SHA512:
6
- metadata.gz: 629cb6c7f875a261ee1285b6e92acf688e51f81efaecd7423fccc14f17bc8e14b54e433a2b02a03abf3bc5c9cc0ddb8c08f3771623340e2e9d16437e448b70ef
7
- data.tar.gz: d38b3a46dc522de7de9cb66e457d6a7e10d0baaa77e432262a1ff3bb01104326a405c4341bce6a1d8d77fc24fdd6b51217c8bc93a364002db364e48bd5581cca
6
+ metadata.gz: 598d9114124c9f842ae708b11922762a3061711a674c29827f8e7c9fc37b0a2095bc510bc1ab5525e8e0131d6ac85447e518ef9e8a4a788f7a1ddb2a3e455b97
7
+ data.tar.gz: 993e073ab06cbbf688d86cbb9f6de10dd587a6bc548c5cb4d53d00af30106ffc89a221e2374a53872490b7b4095a160e0fe11ea18f2de9fb018ae42981043622
data/.gitignore CHANGED
@@ -8,4 +8,5 @@
8
8
  /tmp/
9
9
 
10
10
  /.vagrant/
11
- /ubuntu-xenial-16.04-cloudimg-console.log
11
+ /ubuntu-xenial-16.04-cloudimg-console.log
12
+ /vendor/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,51 @@
1
+ ## 0.4.1 / 2022-06-16
2
+
3
+ * Specifying minimum version of `aws-sdk-core` gem for `jmespath` security issue
4
+
5
+ ## 0.4.0 / 2021-12-03
6
+
7
+ * Added automatic parsing of JSON columns (thanks [darkside](https://github.com/darkside))
8
+
9
+ #### Potentially breaking change
10
+
11
+ 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.
12
+
13
+ For example, with previous versions you could do this (even though it would generate a warning):
14
+
15
+ ```ruby
16
+ > query = conn.execute("SELECT JSON_PARSE('{\"a\": 1, \"b\": 2}');")
17
+ > query.wait
18
+ > JSON.parse(query.to_a(header_row: false).first[0])
19
+ WARNING: Unsupported type: json, defaulting to string
20
+ => {"a"=>1, "b"=>2}
21
+ ```
22
+
23
+ After upgrading, that same code will give you an error:
24
+ ```ruby
25
+ > JSON.parse(query.to_a(header_row: false).first[0])
26
+ Traceback (most recent call last):
27
+ 5: from bin/console:14:in `<main>'
28
+ 4: from (irb):12:in `<main>'
29
+ 3: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `parse'
30
+ 2: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `new'
31
+ 1: from /home/vagrant/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/json/common.rb:216:in `initialize'
32
+ TypeError (no implicit conversion of Hash into String)
33
+ ```
34
+
35
+ Instead just remove your json parsing since Athens handles it now:
36
+ ```ruby
37
+ > query = conn.execute("SELECT JSON_PARSE('{\"a\": 1, \"b\": 2}');")
38
+ > query.wait
39
+ > query.to_a(header_row: false).first[0]
40
+ => {:a=>1, :b=>2}
41
+ ```
42
+
43
+
44
+ ## 0.3.6 / 2021-11-16
45
+
46
+ * Addition of :result_encryption as a configuration option to change encryption options for query results (https://github.com/getletterpress/athens/issues/12)
47
+ * Bumped development gem versions to latest releases
48
+
1
49
  ## 0.3.5 / 2021-05-19
2
50
 
3
51
  * Addition of :aws_profile as a configuration option for credentials (thanks [oisin](https://github.com/oisin))
data/Gemfile.lock CHANGED
@@ -1,26 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- athens (0.3.5)
4
+ athens (0.4.0)
5
5
  aws-sdk-athena (~> 1)
6
+ aws-sdk-core (~> 3.131.1)
7
+ multi_json (~> 1.0)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
9
11
  specs:
10
- aws-eventstream (1.1.1)
11
- aws-partitions (1.458.0)
12
- aws-sdk-athena (1.37.0)
13
- aws-sdk-core (~> 3, >= 3.112.0)
12
+ aws-eventstream (1.2.0)
13
+ aws-partitions (1.599.0)
14
+ aws-sdk-athena (1.53.0)
15
+ aws-sdk-core (~> 3, >= 3.127.0)
14
16
  aws-sigv4 (~> 1.1)
15
- aws-sdk-core (3.114.0)
17
+ aws-sdk-core (3.131.1)
16
18
  aws-eventstream (~> 1, >= 1.0.2)
17
- aws-partitions (~> 1, >= 1.239.0)
19
+ aws-partitions (~> 1, >= 1.525.0)
18
20
  aws-sigv4 (~> 1.1)
19
- jmespath (~> 1.0)
20
- aws-sigv4 (1.2.3)
21
+ jmespath (~> 1, >= 1.6.1)
22
+ aws-sigv4 (1.5.0)
21
23
  aws-eventstream (~> 1, >= 1.0.2)
22
- jmespath (1.4.0)
23
- rake (13.0.3)
24
+ jmespath (1.6.1)
25
+ multi_json (1.15.0)
26
+ rake (13.0.6)
24
27
  rexml (3.2.5)
25
28
 
26
29
  PLATFORMS
data/README.md CHANGED
@@ -92,6 +92,7 @@ Athens.configure do |config|
92
92
  config.aws_profile = 'myprofile' # Optional
93
93
  config.aws_region = 'us-east-1' # Optional
94
94
  config.wait_polling_period = 0.25 # Optional - What period should we poll for the complete query?
95
+ config.result_encryption = nil # Optional, see below
95
96
  end
96
97
  ```
97
98
 
@@ -105,6 +106,14 @@ conn = Athens::Connection.new(aws_client_override: {})
105
106
 
106
107
  Take a look at the [AWS Athena SDK](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Athena/Client.html#initialize-instance_method) for a list of all the available options.
107
108
 
109
+ The `result_encryption` option controls how the Athens results will be encrypted at the `output_location`. By default it's set to use the Amazon SSE encryption if you don't set it at all:
110
+
111
+ ```ruby
112
+ { encryption_option: "SSE_S3" }
113
+ ```
114
+
115
+ If you set it to `nil`, it'll default to the bucket encryption settings. You can also use a customer kms key, see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Athena/Types/EncryptionConfiguration.html for the correct format.
116
+
108
117
  ### Advanced Usage
109
118
 
110
119
  Providing a database name to the connection is optional, if you omit the name you'll have to specify it in your query:
@@ -161,6 +170,12 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
161
170
 
162
171
  If you want you can use Vagrant instead, there's already a `Vagrantfile` so a simple `vagrant up` should get you setup.
163
172
 
173
+ If you want to use Docker, grab a ruby image and boot into the console. Then install git and bash and you can run the `bin/setup` script from there:
174
+
175
+ ```
176
+ docker run --rm -it -v $(pwd):/app -w /app ruby:2.7-alpine /bin/sh -c 'apk add bash git;/bin/bash'
177
+ ```
178
+
164
179
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
165
180
 
166
181
  ## Contributing
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
@@ -34,7 +34,9 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.required_ruby_version = '>= 2.4'
36
36
 
37
+ spec.add_dependency "aws-sdk-core", "~> 3.131.1"
37
38
  spec.add_dependency "aws-sdk-athena", "~> 1"
39
+ spec.add_dependency 'multi_json', '~> 1.0'
38
40
 
39
41
  spec.add_development_dependency "bundler", ">= 1.17"
40
42
  spec.add_development_dependency "rake", "~> 13.0"
data/bin/setup CHANGED
@@ -3,6 +3,7 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
+ gem install bundler:`tail -1 Gemfile.lock | xargs`
6
7
  bundle install
7
8
 
8
9
  # Do any other automated setup that you need to do here
@@ -5,7 +5,8 @@ module Athens
5
5
  :aws_region,
6
6
  :output_location,
7
7
  :wait_polling_period,
8
- :aws_profile
8
+ :aws_profile,
9
+ :result_encryption
9
10
 
10
11
  def initialize
11
12
  @aws_access_key = nil
@@ -14,6 +15,7 @@ module Athens
14
15
  @output_location = nil
15
16
  @wait_polling_period = 0.25
16
17
  @aws_profile = nil
18
+ @result_encryption = { encryption_option: "SSE_S3" }
17
19
  end
18
20
  end
19
21
  end
@@ -48,9 +48,7 @@ module Athens
48
48
  def result_config
49
49
  Aws::Athena::Types::ResultConfiguration.new(
50
50
  output_location: Athens.configuration.output_location,
51
- encryption_configuration: {
52
- encryption_option: "SSE_S3"
53
- }
51
+ encryption_configuration: Athens.configuration.result_encryption
54
52
  )
55
53
  end
56
54
 
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.5"
2
+ VERSION = "0.4.1"
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,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.1
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-05-19 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.131.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.131.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: aws-sdk-athena
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -113,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
141
  - !ruby/object:Gem::Version
114
142
  version: '0'
115
143
  requirements: []
116
- rubygems_version: 3.0.9
144
+ rubygems_version: 3.1.6
117
145
  signing_key:
118
146
  specification_version: 4
119
147
  summary: Run simple SQL queries in AWS Athena