trino-client 2.1.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +10 -0
- data/README.md +13 -0
- data/lib/trino/client/query.rb +6 -3
- data/lib/trino/client/statement_client.rb +2 -1
- data/lib/trino/client/version.rb +1 -1
- data/trino-client.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44518a87285ae0051f9543aa73cb869a5d34c355adea490ee43107a88476e56
|
4
|
+
data.tar.gz: 28a0d53b23d0a74a165e1c83d5c9cfbe87fe926d885c0f5eb8161d7c39c1fa8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39630d06e5b300f764c1b861a488c63bbe7c465eee0dc0d8b1979904194429a33c2685a67e47c4c81904fd39e604aa4ed2e4ec93263594f872b924061ad543e3
|
7
|
+
data.tar.gz: 77c635eed6243bdb7eaccace39a2aee3e22fe8c0654b514644f1acb7d374fb365de7c4920daa72e1a647aa3b4406388ab6b59ef5900f5e4d7807053dc081c2c1
|
data/ChangeLog.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
trino-client-ruby
|
2
2
|
====
|
3
|
+
## 2.2.1
|
4
|
+
- fix: Retry GET against 502, 503 responses ([#129](https://github.com/treasure-data/trino-client-ruby/issues/129)) [[80f342d](https://github.com/treasure-data/trino-client-ruby/commit/80f342d)]
|
5
|
+
- Update CODEOWNERS ([#127](https://github.com/treasure-data/trino-client-ruby/issues/127)) [[bad4b34](https://github.com/treasure-data/trino-client-ruby/commit/bad4b34)]
|
6
|
+
- Update rspec requirement from ~> 3.12.0 to ~> 3.13.0 ([#124](https://github.com/treasure-data/trino-client-ruby/issues/124)) [[6716716](https://github.com/treasure-data/trino-client-ruby/commit/6716716)]
|
7
|
+
- Bump release-drafter/release-drafter from 5 to 6 ([#125](https://github.com/treasure-data/trino-client-ruby/issues/125)) [[0c808c2](https://github.com/treasure-data/trino-client-ruby/commit/0c808c2)]
|
8
|
+
- Bump github/codeql-action from 2 to 3 ([#123](https://github.com/treasure-data/trino-client-ruby/issues/123)) [[c9d9356](https://github.com/treasure-data/trino-client-ruby/commit/c9d9356)]
|
9
|
+
|
10
|
+
## 2.2.0
|
11
|
+
- Add transform_row and scalar_parser documentation and make them easier to use ([#118](https://github.com/treasure-data/trino-client-ruby/issues/118)) [[41ffca7](https://github.com/treasure-data/trino-client-ruby/commit/41ffca7)]
|
12
|
+
|
3
13
|
## 2.1.0
|
4
14
|
- Add utility for transforming Trino ROW type columns into Ruby hashes ([#117](https://github.com/treasure-data/trino-client-ruby/issues/117)) [[e14251c](https://github.com/treasure-data/trino-client-ruby/commit/e14251c)]
|
5
15
|
- Bump actions/checkout from 3 to 4 ([#116](https://github.com/treasure-data/trino-client-ruby/issues/116)) [[ebd9d9e](https://github.com/treasure-data/trino-client-ruby/commit/ebd9d9e)]
|
data/README.md
CHANGED
@@ -64,6 +64,19 @@ query = client.query("select * from sys.node")
|
|
64
64
|
query_id = query.query_info.query_id
|
65
65
|
query.each_row {|row| ... } # when a thread is processing the query,
|
66
66
|
client.kill(query_id) # another thread / process can kill the query.
|
67
|
+
|
68
|
+
# Use Query#transform_row to parse Trino ROW types into Ruby Hashes.
|
69
|
+
# You can also set a scalar_parser to parse scalars how you'd like them.
|
70
|
+
scalar_parser = -> (data, type) { (type === 'json') ? JSON.parse(data) : data }
|
71
|
+
client.query("select * from sys.node") do |q|
|
72
|
+
q.scalar_parser = scalar_parser
|
73
|
+
|
74
|
+
# get query results. it feeds more rows until
|
75
|
+
# query execution finishes:
|
76
|
+
q.each_row {|row|
|
77
|
+
p q.transform_row(row)
|
78
|
+
}
|
79
|
+
end
|
67
80
|
```
|
68
81
|
|
69
82
|
## Build models
|
data/lib/trino/client/query.rb
CHANGED
@@ -58,6 +58,8 @@ module Trino::Client
|
|
58
58
|
row_object
|
59
59
|
end
|
60
60
|
|
61
|
+
attr_accessor :scalar_parser
|
62
|
+
|
61
63
|
def initialize(api)
|
62
64
|
@api = api
|
63
65
|
end
|
@@ -101,13 +103,14 @@ module Trino::Client
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def column_value_parsers
|
104
|
-
@column_value_parsers ||=
|
105
|
-
|
106
|
+
@column_value_parsers ||= {}
|
107
|
+
@column_value_parsers[scalar_parser] ||= columns.map {|column|
|
108
|
+
ColumnValueParser.new(column, scalar_parser)
|
106
109
|
}
|
107
110
|
end
|
108
111
|
|
109
112
|
def transform_rows
|
110
|
-
rows.map(
|
113
|
+
rows.map { |row| transform_row(row) }
|
111
114
|
end
|
112
115
|
|
113
116
|
def transform_row(row)
|
@@ -208,7 +208,8 @@ module Trino::Client
|
|
208
208
|
return response
|
209
209
|
end
|
210
210
|
|
211
|
-
if
|
211
|
+
# retry if 502, 503, 504 according to the trino protocol
|
212
|
+
unless [502, 503, 504].include?(response.status)
|
212
213
|
# deterministic error
|
213
214
|
exception! TrinoHttpError.new(response.status, "Trino API error at #{uri} returned #{response.status}: #{response.body}")
|
214
215
|
end
|
data/lib/trino/client/version.rb
CHANGED
data/trino-client.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency "msgpack", [">= 1.5.1"]
|
24
24
|
|
25
25
|
gem.add_development_dependency "rake", [">= 0.9.2", "< 14.0"]
|
26
|
-
gem.add_development_dependency "rspec", "~> 3.
|
26
|
+
gem.add_development_dependency "rspec", "~> 3.13.0"
|
27
27
|
gem.add_development_dependency "webmock", ["~> 3.0"]
|
28
28
|
gem.add_development_dependency "addressable", "~> 2.8.1" # 2.5.0 doesn't support Ruby 1.9.3
|
29
29
|
gem.add_development_dependency "simplecov", "~> 0.22.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trino-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -98,14 +98,14 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 3.
|
101
|
+
version: 3.13.0
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 3.
|
108
|
+
version: 3.13.0
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: webmock
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|