athena-utils 0.1.1 → 0.2.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 +4 -4
- data/athena-utils.gemspec +1 -1
- data/bin/athena +24 -10
- data/lib/athena_utils/athena_client.rb +5 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90313673159e89c11d9e5a349cf25ba6f36c8a1b2e0842aede4077b4bd4591e2
|
4
|
+
data.tar.gz: cc06774cad38266f57b842dbd75c05f82b2a39502c4c4918653f1a8becd8e8f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9d081001c9d3df09e9c168eaf1b9ae3b9efef68304de3f7bee46f58faac5ba661cdcab389a1c41930c92673f6bce55f1b123e39fbc258789c62ffbfd7607ab9
|
7
|
+
data.tar.gz: c95477b1c4a8f13c6e3ad9433c0ebe123b56b4446799c70bf7c345c1e4a447742ca246dba2a6a015711e576a7018d679dc5b19145df5b2b178860ce2ab1054fa
|
data/athena-utils.gemspec
CHANGED
data/bin/athena
CHANGED
@@ -5,9 +5,10 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
options = {
|
7
7
|
database: nil,
|
8
|
-
|
8
|
+
work_group: 'primary',
|
9
9
|
query: nil,
|
10
|
-
save: nil
|
10
|
+
save: nil,
|
11
|
+
console: false
|
11
12
|
}
|
12
13
|
OptionParser.new do |opts|
|
13
14
|
opts.banner = "Usage: athena [options]"
|
@@ -16,8 +17,8 @@ OptionParser.new do |opts|
|
|
16
17
|
options[:database] = v
|
17
18
|
end
|
18
19
|
|
19
|
-
opts.on("-
|
20
|
-
options[:
|
20
|
+
opts.on("-w WORK_GROUP", "Athena Work Group, default: primary") do |v|
|
21
|
+
options[:work_group] = v
|
21
22
|
end
|
22
23
|
|
23
24
|
opts.on("-e", "--execute QUERY", "Execute SQL Query") do |v|
|
@@ -27,12 +28,16 @@ OptionParser.new do |opts|
|
|
27
28
|
opts.on('-s', '--save FILE', 'Save query results to file') do |v|
|
28
29
|
options[:save] = v
|
29
30
|
end
|
31
|
+
|
32
|
+
opts.on('-c', '--console', 'Execute query and makes results available in irb') do
|
33
|
+
options[:console] = true
|
34
|
+
end
|
30
35
|
end.parse!
|
31
36
|
|
32
37
|
raise('must specify a database') unless options[:database]
|
33
|
-
raise('must specify
|
38
|
+
raise('must specify work group for athean queries') unless options[:work_group]
|
34
39
|
|
35
|
-
@athena = AthenaUtils::AthenaClient.new(options[:database], options[:
|
40
|
+
@athena = AthenaUtils::AthenaClient.new(options[:database], options[:work_group])
|
36
41
|
def athena
|
37
42
|
@athena
|
38
43
|
end
|
@@ -47,8 +52,17 @@ if options[:query]
|
|
47
52
|
results.save(options[:save])
|
48
53
|
exit
|
49
54
|
end
|
50
|
-
end
|
51
|
-
|
52
|
-
require 'irb'
|
53
|
-
IRB.start
|
54
55
|
|
56
|
+
if options[:console]
|
57
|
+
require 'irb'
|
58
|
+
IRB.start
|
59
|
+
else
|
60
|
+
io = results.s3_object.body
|
61
|
+
while chunk = io.read(8192)
|
62
|
+
print chunk
|
63
|
+
end
|
64
|
+
end
|
65
|
+
else
|
66
|
+
require 'irb'
|
67
|
+
IRB.start
|
68
|
+
end
|
@@ -5,9 +5,9 @@ module AthenaUtils
|
|
5
5
|
DEFAULT_WAIT_TIME = 3 # seconds
|
6
6
|
|
7
7
|
# database is the name of the Athena DB
|
8
|
-
#
|
8
|
+
# work_group is Athena Work Group to use with queries
|
9
9
|
attr_reader :database,
|
10
|
-
:
|
10
|
+
:work_group
|
11
11
|
|
12
12
|
# wait_time is time to wait before checking query results again
|
13
13
|
attr_accessor :wait_time
|
@@ -15,9 +15,9 @@ module AthenaUtils
|
|
15
15
|
attr_writer :aws_athena_client,
|
16
16
|
:aws_s3_client
|
17
17
|
|
18
|
-
def initialize(database,
|
18
|
+
def initialize(database, work_group, wait_time = DEFAULT_WAIT_TIME)
|
19
19
|
@database = database
|
20
|
-
@
|
20
|
+
@work_group = work_group
|
21
21
|
@wait_time = wait_time
|
22
22
|
end
|
23
23
|
|
@@ -48,9 +48,7 @@ module AthenaUtils
|
|
48
48
|
query_execution_context: {
|
49
49
|
database: database
|
50
50
|
},
|
51
|
-
|
52
|
-
output_location: output_location
|
53
|
-
}
|
51
|
+
work_group: work_group
|
54
52
|
)
|
55
53
|
|
56
54
|
response.query_execution_id
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: athena-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-athena
|