athens 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -0
- data/lib/athens/query.rb +26 -38
- data/lib/athens/version.rb +1 -1
- 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: 901ae482186b3f1eeb424ee6bc4c09f5122aa7ba20028e7bc88015f0f8eff840
|
4
|
+
data.tar.gz: a42a0b004300dd61da4d1bf3fc96aace76c94fa0ba7760a8ca81a4a736cb77e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89fc662abb5ee87ab4612ddc90cadfb2259f0e33e6e3d59a73f0b759dbf675239630ef9f8835d88746ad72726404eb9db5d451eb5d84ad0bdcb4c1ceffd23c5
|
7
|
+
data.tar.gz: c15ce346a50f27fd2f684928bf1761145b848b1d80b9503faad4b5ffcd3cf35b49aa8d3fe719bd6da0210e2a5094cc0ff3e7a38026e1361521f8404738d09fca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.3.0 / 2019-07-02
|
2
|
+
|
3
|
+
* Added enumerator-based result access methods: `#rows` and `#records`
|
4
|
+
* Fixed bug dropping headers from memoized rows across `#to_h` and `#to_a(header_row: true)`
|
5
|
+
|
1
6
|
## 0.2.0 / 2019-03-20
|
2
7
|
|
3
8
|
* Added support for NULL values. Columns with a nullable status of "NULLABLE" or "UNKNOWN" will return nil for NULL values
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -61,6 +61,23 @@ results = query.to_h
|
|
61
61
|
# ]
|
62
62
|
```
|
63
63
|
|
64
|
+
Results are also available as unbuffered enumerators of row arrays:
|
65
|
+
```ruby
|
66
|
+
query.rows.each {|row| ...}
|
67
|
+
# ['column_1', 'column_2', 'column_3']
|
68
|
+
# [15, 'data', true]
|
69
|
+
# [20, 'foo', false],
|
70
|
+
# ...
|
71
|
+
```
|
72
|
+
|
73
|
+
Or hashes:
|
74
|
+
```ruby
|
75
|
+
query.records.each {|record| ...}
|
76
|
+
# {'column_1': 15, 'column_2': 'data', 'column_3': true}
|
77
|
+
# {'column_1': 20, 'column_2': 'foo', 'column_3': false}
|
78
|
+
# ...
|
79
|
+
```
|
80
|
+
|
64
81
|
Athens attempts to parse the sql data types into their ruby equivalents, although there's currently no support for the more complex Array/Map types.
|
65
82
|
|
66
83
|
### Configuration
|
data/lib/athens/query.rb
CHANGED
@@ -69,12 +69,10 @@ module Athens
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def rows
|
73
73
|
raise InvalidRequestError.new("Query must be in SUCCEEDED state to return results") unless @state == 'SUCCEEDED'
|
74
74
|
|
75
|
-
|
76
|
-
# Need to load and map all of the rows from the original result
|
77
|
-
@results = []
|
75
|
+
Enumerator.new do |y|
|
78
76
|
result = @connection.client.get_query_results({query_execution_id: @query_execution_id})
|
79
77
|
|
80
78
|
metadata = result.result_set.result_set_metadata
|
@@ -85,53 +83,43 @@ module Athens
|
|
85
83
|
break if rows.empty?
|
86
84
|
|
87
85
|
if first
|
88
|
-
|
86
|
+
y << rows.shift.data.map {|col| col.var_char_value}
|
89
87
|
first = false
|
90
88
|
end
|
91
89
|
|
92
|
-
rows.each
|
93
|
-
@results << map_types(metadata, row)
|
94
|
-
end
|
90
|
+
rows.each {|row| y << map_types(metadata, row)}
|
95
91
|
|
96
|
-
|
97
|
-
result = @connection.client.get_query_results({
|
98
|
-
query_execution_id: @query_execution_id,
|
99
|
-
next_token: result.next_token
|
100
|
-
})
|
101
|
-
else
|
102
|
-
# No more rows, break out and return our mapped data
|
103
|
-
break
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
92
|
+
break unless result.next_token
|
107
93
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
94
|
+
result = @connection.client.get_query_results({
|
95
|
+
query_execution_id: @query_execution_id,
|
96
|
+
next_token: result.next_token
|
97
|
+
})
|
98
|
+
end
|
112
99
|
end
|
113
100
|
end
|
114
101
|
|
115
|
-
def
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
headers = all_rows.shift
|
120
|
-
|
121
|
-
@hash_results = []
|
102
|
+
def records
|
103
|
+
Enumerator.new do |y|
|
104
|
+
headers = nil
|
122
105
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
map[header] = row[index]
|
128
|
-
end
|
129
|
-
@hash_results << map
|
106
|
+
rows.each_with_index do |row|
|
107
|
+
if headers.nil?
|
108
|
+
headers = row
|
109
|
+
next
|
130
110
|
end
|
111
|
+
|
112
|
+
y << Hash[headers.zip(row)]
|
131
113
|
end
|
132
114
|
end
|
115
|
+
end
|
133
116
|
|
134
|
-
|
117
|
+
def to_a(header_row: true)
|
118
|
+
(@results ||= rows.to_a).drop(header_row ? 0 : 1)
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_h
|
122
|
+
@hash_results ||= records.to_a
|
135
123
|
end
|
136
124
|
|
137
125
|
private
|
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.
|
4
|
+
version: 0.3.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: 2019-
|
11
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-athena
|