athens 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +18 -15
- data/README.md +16 -6
- data/Rakefile +0 -1
- data/athens.gemspec +4 -3
- data/lib/athens/configuration.rb +7 -3
- data/lib/athens/connection.rb +9 -6
- data/lib/athens/query.rb +4 -4
- data/lib/athens/version.rb +1 -1
- metadata +25 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0751e4a11947a14a576b1a2b251c53af99a90b7b88e15617f810767efb3cce9
|
4
|
+
data.tar.gz: a6dbc5ef43c672a80df58c68159614c02a25a4b377039111d68ac104d9712473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 629cb6c7f875a261ee1285b6e92acf688e51f81efaecd7423fccc14f17bc8e14b54e433a2b02a03abf3bc5c9cc0ddb8c08f3771623340e2e9d16437e448b70ef
|
7
|
+
data.tar.gz: d38b3a46dc522de7de9cb66e457d6a7e10d0baaa77e432262a1ff3bb01104326a405c4341bce6a1d8d77fc24fdd6b51217c8bc93a364002db364e48bd5581cca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## 0.3.5 / 2021-05-19
|
2
|
+
|
3
|
+
* Addition of :aws_profile as a configuration option for credentials (thanks [oisin](https://github.com/oisin))
|
4
|
+
* Fix for BigDecimal in Ruby 3.x (thanks [mediafinger](https://github.com/mediafinger))
|
5
|
+
* Bumped development gem versions to latest releases
|
6
|
+
|
7
|
+
## 0.3.4 / 2021-03-02
|
8
|
+
|
9
|
+
* Added configurable polling period (thanks [jesseproudman](https://github.com/jesseproudman))
|
10
|
+
|
11
|
+
## 0.3.3 / 2021-01-12
|
12
|
+
|
13
|
+
* Added support for Ruby 3.0 (thanks [blackjiro](https://github.com/blackjiro))
|
14
|
+
|
15
|
+
## 0.3.2 / 2020-11-24
|
16
|
+
|
17
|
+
* Added optional `request_token` and `work_group` parameters to the query execute method (thanks [mediafinger](https://github.com/mediafinger))
|
18
|
+
|
19
|
+
## 0.3.1 / 2020-07-20
|
20
|
+
|
21
|
+
* Bumped development rake version from 0.10 to 0.13 for security fixes
|
22
|
+
* Fixed warning about string defaulting to string (#2)
|
23
|
+
|
1
24
|
## 0.3.0 / 2019-07-02
|
2
25
|
|
3
26
|
* Added enumerator-based result access methods: `#rows` and `#records`
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,36 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
athens (0.3.
|
4
|
+
athens (0.3.5)
|
5
5
|
aws-sdk-athena (~> 1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
aws-eventstream (1.
|
11
|
-
aws-partitions (1.
|
12
|
-
aws-sdk-athena (1.
|
13
|
-
aws-sdk-core (~> 3, >= 3.
|
14
|
-
aws-sigv4 (~> 1.
|
15
|
-
aws-sdk-core (3.
|
16
|
-
aws-eventstream (~> 1.0)
|
17
|
-
aws-partitions (~> 1.0)
|
18
|
-
aws-sigv4 (~> 1.
|
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)
|
14
|
+
aws-sigv4 (~> 1.1)
|
15
|
+
aws-sdk-core (3.114.0)
|
16
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
17
|
+
aws-partitions (~> 1, >= 1.239.0)
|
18
|
+
aws-sigv4 (~> 1.1)
|
19
19
|
jmespath (~> 1.0)
|
20
|
-
aws-sigv4 (1.
|
20
|
+
aws-sigv4 (1.2.3)
|
21
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
21
22
|
jmespath (1.4.0)
|
22
|
-
rake (
|
23
|
+
rake (13.0.3)
|
24
|
+
rexml (3.2.5)
|
23
25
|
|
24
26
|
PLATFORMS
|
25
27
|
ruby
|
26
28
|
|
27
29
|
DEPENDENCIES
|
28
30
|
athens!
|
29
|
-
bundler (
|
30
|
-
rake (~>
|
31
|
+
bundler (>= 1.17)
|
32
|
+
rake (~> 13.0)
|
33
|
+
rexml (~> 3.2)
|
31
34
|
|
32
35
|
BUNDLED WITH
|
33
|
-
|
36
|
+
2.2.5
|
data/README.md
CHANGED
@@ -44,8 +44,8 @@ When your query is done, grab the results as an array:
|
|
44
44
|
```ruby
|
45
45
|
results = query.to_a
|
46
46
|
# [
|
47
|
-
# ['column_1', 'column_2', 'column_3'],
|
48
|
-
# [15, 'data', true],
|
47
|
+
# ['column_1', 'column_2', 'column_3'],
|
48
|
+
# [15, 'data', true],
|
49
49
|
# [20, 'foo', false],
|
50
50
|
# ...
|
51
51
|
# ]
|
@@ -55,7 +55,7 @@ Or as a hash (which is really an array where each row is a hash):
|
|
55
55
|
```ruby
|
56
56
|
results = query.to_h
|
57
57
|
# [
|
58
|
-
# {'column_1': 15, 'column_2': 'data', 'column_3': true},
|
58
|
+
# {'column_1': 15, 'column_2': 'data', 'column_3': true},
|
59
59
|
# {'column_1': 20, 'column_2': 'foo', 'column_3': false},
|
60
60
|
# ...
|
61
61
|
# ]
|
@@ -87,9 +87,11 @@ Configure your AWS settings in an `Athens.configure` block (in rails put this in
|
|
87
87
|
```ruby
|
88
88
|
Athens.configure do |config|
|
89
89
|
config.output_location = "s3://my-bucket/my-folder/athena/results/" # Required
|
90
|
-
config.aws_access_key
|
91
|
-
config.aws_secret_key
|
92
|
-
config.
|
90
|
+
config.aws_access_key = 'access' # Optional
|
91
|
+
config.aws_secret_key = 'secret' # Optional
|
92
|
+
config.aws_profile = 'myprofile' # Optional
|
93
|
+
config.aws_region = 'us-east-1' # Optional
|
94
|
+
config.wait_polling_period = 0.25 # Optional - What period should we poll for the complete query?
|
93
95
|
end
|
94
96
|
```
|
95
97
|
|
@@ -146,6 +148,13 @@ query.cancel # Attempts to cancel an in-progress query, returns true or false
|
|
146
148
|
query.to_a(header_row: false) # If you want your query results returned without a header row of column names
|
147
149
|
```
|
148
150
|
|
151
|
+
The execute method also optionally supports the `request_token` and `work_group` [parameters](https://docs.aws.amazon.com/athena/latest/APIReference/API_StartQueryExecution.html#API_StartQueryExecution_RequestSyntax):
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
conn = Athens::Connection.new(database: 'sample')
|
155
|
+
query = conn.execute("SELECT * FROM mytable", request_token: single_use_token, work_group: my_work_group)
|
156
|
+
```
|
157
|
+
|
149
158
|
## Development
|
150
159
|
|
151
160
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -165,3 +174,4 @@ The gem is available as open source under the terms of the [WTFPL License](http:
|
|
165
174
|
## Code of Conduct
|
166
175
|
|
167
176
|
Everyone interacting in the Athens project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/getletterpress/athens/blob/master/CODE_OF_CONDUCT.md).
|
177
|
+
|
data/Rakefile
CHANGED
data/athens.gemspec
CHANGED
@@ -32,10 +32,11 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
|
35
|
-
spec.required_ruby_version = '
|
35
|
+
spec.required_ruby_version = '>= 2.4'
|
36
36
|
|
37
37
|
spec.add_dependency "aws-sdk-athena", "~> 1"
|
38
38
|
|
39
|
-
spec.add_development_dependency "bundler", "
|
40
|
-
spec.add_development_dependency "rake", "~>
|
39
|
+
spec.add_development_dependency "bundler", ">= 1.17"
|
40
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
41
|
+
spec.add_development_dependency "rexml", "~> 3.2"
|
41
42
|
end
|
data/lib/athens/configuration.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
module Athens
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :aws_access_key,
|
3
|
+
attr_accessor :aws_access_key,
|
4
4
|
:aws_secret_key,
|
5
5
|
:aws_region,
|
6
|
-
:output_location
|
6
|
+
:output_location,
|
7
|
+
:wait_polling_period,
|
8
|
+
:aws_profile
|
7
9
|
|
8
10
|
def initialize
|
9
11
|
@aws_access_key = nil
|
10
12
|
@aws_secret_key = nil
|
11
13
|
@aws_region = nil
|
12
14
|
@output_location = nil
|
15
|
+
@wait_polling_period = 0.25
|
16
|
+
@aws_profile = nil
|
13
17
|
end
|
14
18
|
end
|
15
|
-
end
|
19
|
+
end
|
data/lib/athens/connection.rb
CHANGED
@@ -8,10 +8,11 @@ module Athens
|
|
8
8
|
def initialize(database: nil, aws_client_override: {})
|
9
9
|
@database_name = database
|
10
10
|
|
11
|
-
client_config = {
|
11
|
+
client_config = {
|
12
12
|
access_key_id: Athens.configuration.aws_access_key,
|
13
13
|
secret_access_key: Athens.configuration.aws_secret_key,
|
14
|
-
region: Athens.configuration.aws_region
|
14
|
+
region: Athens.configuration.aws_region,
|
15
|
+
profile: Athens.configuration.aws_profile
|
15
16
|
}.merge(aws_client_override).compact
|
16
17
|
|
17
18
|
@client = Aws::Athena::Client.new(client_config)
|
@@ -19,26 +20,28 @@ module Athens
|
|
19
20
|
|
20
21
|
# Runs a query against Athena, returning an Athens::Query object
|
21
22
|
# that you can use to wait for it to finish or get the results
|
22
|
-
def execute(query)
|
23
|
+
def execute(query, request_token: nil, work_group: nil)
|
23
24
|
if @database_name
|
24
25
|
resp = @client.start_query_execution(
|
25
26
|
query_string: query,
|
26
27
|
query_execution_context: context,
|
27
|
-
result_configuration: result_config
|
28
|
+
result_configuration: result_config,
|
29
|
+
client_request_token: request_token,
|
30
|
+
work_group: work_group
|
28
31
|
)
|
29
32
|
else
|
30
33
|
resp = @client.start_query_execution(
|
31
34
|
query_string: query,
|
32
35
|
result_configuration: result_config
|
33
36
|
)
|
34
|
-
end
|
37
|
+
end
|
35
38
|
|
36
39
|
return Athens::Query.new(self, resp.query_execution_id)
|
37
40
|
end
|
38
41
|
|
39
42
|
private
|
40
43
|
|
41
|
-
def context
|
44
|
+
def context
|
42
45
|
Aws::Athena::Types::QueryExecutionContext.new(database: @database_name)
|
43
46
|
end
|
44
47
|
|
data/lib/athens/query.rb
CHANGED
@@ -14,6 +14,7 @@ module Athens
|
|
14
14
|
|
15
15
|
version = RUBY_VERSION.split('.').map {|v| v.to_i}
|
16
16
|
@decimal_without_new = (version[0] >= 2 && version[1] >= 5)
|
17
|
+
@decimal_without_new = (version[0] == 2 && version[1] >= 5) || (version[0] >= 3)
|
17
18
|
end
|
18
19
|
|
19
20
|
def state
|
@@ -49,7 +50,7 @@ module Athens
|
|
49
50
|
end
|
50
51
|
|
51
52
|
# Wait a bit and check again
|
52
|
-
sleep(
|
53
|
+
sleep(Athens.configuration.wait_polling_period.to_f)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -151,7 +152,7 @@ module Athens
|
|
151
152
|
mapped << data.to_i
|
152
153
|
when 'timestamp'
|
153
154
|
mapped << Time.parse(data)
|
154
|
-
when 'varchar'
|
155
|
+
when 'varchar', 'string'
|
155
156
|
mapped << data
|
156
157
|
when 'float', 'double'
|
157
158
|
mapped << data.to_f
|
@@ -173,9 +174,8 @@ module Athens
|
|
173
174
|
end
|
174
175
|
|
175
176
|
return mapped
|
176
|
-
end
|
177
|
+
end
|
177
178
|
|
178
179
|
|
179
180
|
end
|
180
181
|
end
|
181
|
-
|
data/lib/athens/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schulte
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-athena
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.17'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.17'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rexml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.2'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '3.2'
|
55
69
|
description: Allows you to easily access AWS Athena databases and run queries
|
56
70
|
email:
|
57
71
|
- chris@oceanbreezesoftware.com
|
@@ -84,13 +98,13 @@ metadata:
|
|
84
98
|
homepage_uri: https://github.com/getletterpress/athens
|
85
99
|
source_code_uri: https://github.com/getletterpress/athens
|
86
100
|
changelog_uri: https://github.com/getletterpress/athens/CHANGELOG.md
|
87
|
-
post_install_message:
|
101
|
+
post_install_message:
|
88
102
|
rdoc_options: []
|
89
103
|
require_paths:
|
90
104
|
- lib
|
91
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- - "
|
107
|
+
- - ">="
|
94
108
|
- !ruby/object:Gem::Version
|
95
109
|
version: '2.4'
|
96
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -99,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
113
|
- !ruby/object:Gem::Version
|
100
114
|
version: '0'
|
101
115
|
requirements: []
|
102
|
-
|
103
|
-
|
104
|
-
signing_key:
|
116
|
+
rubygems_version: 3.0.9
|
117
|
+
signing_key:
|
105
118
|
specification_version: 4
|
106
119
|
summary: Run simple SQL queries in AWS Athena
|
107
120
|
test_files: []
|