trino-client 2.2.0 → 2.2.3
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/.pre-commit-config.yaml +15 -0
- data/CLAUDE.md +74 -0
- data/ChangeLog.md +18 -0
- data/lib/trino/client/client.rb +2 -2
- data/lib/trino/client/statement_client.rb +4 -1
- data/lib/trino/client/version.rb +1 -1
- data/trino-client.gemspec +7 -3
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c843bb17e992cc4b85e75d9c42b1d28defaab68b26226bd3f5157c9d3f66904
|
4
|
+
data.tar.gz: ade30ecd070ae456b719d3339bde72fd3e869a939f1a51dca5044015fd999f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054b13b290fb880b8813a04803fd51d9d131ad225ed496b2fdc9df1c7441314692d6d52809fa3bfcafdb15dbebeebcfa94472e6dacbc4358ecc704c7264d8fed
|
7
|
+
data.tar.gz: 03674c67087e069bbf0976f612260da62987d394fa262d717a5f11dd1677f7e1fd4b326cc6609e0c9676e953052435516114199f4d09c2276955a37dc440e20d
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
repos:
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
4
|
+
rev: v4.6.0
|
5
|
+
hooks:
|
6
|
+
- id: trailing-whitespace
|
7
|
+
- id: end-of-file-fixer
|
8
|
+
- id: check-yaml
|
9
|
+
- id: check-added-large-files
|
10
|
+
- id: check-merge-conflict
|
11
|
+
- id: check-json
|
12
|
+
- id: check-case-conflict
|
13
|
+
- id: mixed-line-ending
|
14
|
+
args: ['--fix=lf']
|
15
|
+
- id: forbid-submodules
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# CLAUDE.md
|
2
|
+
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
4
|
+
|
5
|
+
## Development Commands
|
6
|
+
|
7
|
+
### Testing
|
8
|
+
- `bundle exec rake spec` - Run all RSpec tests
|
9
|
+
- `bundle exec rspec spec/[filename]_spec.rb` - Run specific test file
|
10
|
+
|
11
|
+
### Building
|
12
|
+
- `bundle exec rake build` - Build the gem
|
13
|
+
- `bundle exec rake` - Default task (runs spec and build)
|
14
|
+
|
15
|
+
### Code Quality
|
16
|
+
- `bundle exec standardrb` - Run StandardRB linter (code style enforcement)
|
17
|
+
- `bundle exec standardrb --fix` - Auto-fix style issues
|
18
|
+
|
19
|
+
### Model Generation
|
20
|
+
- `bundle exec rake modelgen:latest` - Generate model files from latest Trino version
|
21
|
+
- `bundle exec rake modelgen:all` - Generate all model versions
|
22
|
+
|
23
|
+
## Architecture Overview
|
24
|
+
|
25
|
+
This is a Ruby client library for Trino (distributed SQL query engine). The architecture is layered:
|
26
|
+
|
27
|
+
### Core Components
|
28
|
+
|
29
|
+
1. **Client Layer** (`lib/trino/client/client.rb`):
|
30
|
+
- `Trino::Client::Client` - Main API entry point
|
31
|
+
- Provides `run()`, `run_with_names()`, `query()`, `kill()` methods
|
32
|
+
- Handles synchronous and streaming query execution
|
33
|
+
|
34
|
+
2. **Query Layer** (`lib/trino/client/query.rb`):
|
35
|
+
- `Query` class - Manages query execution lifecycle
|
36
|
+
- Handles streaming results via `each_row`, `each_row_chunk`
|
37
|
+
- Provides column metadata and result transformation
|
38
|
+
|
39
|
+
3. **Statement Client** (`lib/trino/client/statement_client.rb`):
|
40
|
+
- `StatementClient` - Low-level HTTP communication with Trino
|
41
|
+
- Manages query state machine (running, finished, failed, aborted)
|
42
|
+
- Handles retries, timeouts, and error conditions
|
43
|
+
- Supports both JSON and MessagePack response formats
|
44
|
+
|
45
|
+
4. **HTTP Layer** (`lib/trino/client/faraday_client.rb`):
|
46
|
+
- Uses Faraday for HTTP requests with middleware for gzip and redirects
|
47
|
+
- Handles authentication, SSL configuration, proxy settings
|
48
|
+
|
49
|
+
### Model System
|
50
|
+
|
51
|
+
- **Versioned Models** (`lib/trino/client/model_versions/`):
|
52
|
+
- Generated from Trino source code for different Trino versions
|
53
|
+
- Each version (351, 316, 303, etc.) has its own model definitions
|
54
|
+
- Default is version 351
|
55
|
+
|
56
|
+
- **Model Generation** (`modelgen/`):
|
57
|
+
- Automated model generation from Trino Java source
|
58
|
+
- Downloads Trino source and extracts model definitions
|
59
|
+
|
60
|
+
### Key Features
|
61
|
+
|
62
|
+
- **Streaming Results**: Query results can be processed row-by-row without loading all data into memory
|
63
|
+
- **Timeout Control**: Supports both query-level and plan-level timeouts
|
64
|
+
- **Error Recovery**: Built-in retry logic for transient failures (502, 503, 504)
|
65
|
+
- **Multiple Result Formats**: Raw arrays, named hashes, or streaming iteration
|
66
|
+
- **ROW Type Support**: Can parse Trino ROW types into Ruby hashes via `transform_row`
|
67
|
+
|
68
|
+
### Testing
|
69
|
+
|
70
|
+
Tests are organized by component:
|
71
|
+
- `spec/client_spec.rb` - Client API tests
|
72
|
+
- `spec/statement_client_spec.rb` - Low-level protocol tests
|
73
|
+
- `spec/column_value_parser_spec.rb` - Data parsing tests
|
74
|
+
- `spec/tpch_query_spec.rb` - Integration tests with TPC-H queries
|
data/ChangeLog.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
trino-client-ruby
|
2
2
|
====
|
3
|
+
## 2.2.3
|
4
|
+
- Add .github/workflows/publisher.yml [[f9643b2](https://github.com/treasure-data/trino-client-ruby/commit/f9643b2)]
|
5
|
+
- Bump actions/checkout from 4 to 5 ([#141](https://github.com/treasure-data/trino-client-ruby/issues/141)) [[61372d4](https://github.com/treasure-data/trino-client-ruby/commit/61372d4)]
|
6
|
+
- Update standard requirement from ~> 1.35.0 to ~> 1.50.0 ([#139](https://github.com/treasure-data/trino-client-ruby/issues/139)) [[e4c95a6](https://github.com/treasure-data/trino-client-ruby/commit/e4c95a6)]
|
7
|
+
- misc: Add CLAUDE.md and etc ([#138](https://github.com/treasure-data/trino-client-ruby/issues/138)) [[1a0e975](https://github.com/treasure-data/trino-client-ruby/commit/1a0e975)]
|
8
|
+
|
9
|
+
## 2.2.2
|
10
|
+
- Close StatementClient when hitting client-side timeout ([#136](https://github.com/treasure-data/trino-client-ruby/issues/136)) [[b3261b1](https://github.com/treasure-data/trino-client-ruby/commit/b3261b1)]
|
11
|
+
- Tune Ruby versions in CI / Drop ruby 2.7, 3.0 and 3.1 supports ([#135](https://github.com/treasure-data/trino-client-ruby/issues/135)) [[da87c84](https://github.com/treasure-data/trino-client-ruby/commit/da87c84)]
|
12
|
+
- Update standard requirement from ~> 1.30.1 to ~> 1.35.0 ([#132](https://github.com/treasure-data/trino-client-ruby/issues/132)) [[4f05141](https://github.com/treasure-data/trino-client-ruby/commit/4f05141)]
|
13
|
+
|
14
|
+
## 2.2.1
|
15
|
+
- 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)]
|
16
|
+
- Update CODEOWNERS ([#127](https://github.com/treasure-data/trino-client-ruby/issues/127)) [[bad4b34](https://github.com/treasure-data/trino-client-ruby/commit/bad4b34)]
|
17
|
+
- 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)]
|
18
|
+
- 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)]
|
19
|
+
- 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)]
|
20
|
+
|
3
21
|
## 2.2.0
|
4
22
|
- 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)]
|
5
23
|
|
data/lib/trino/client/client.rb
CHANGED
@@ -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
|
@@ -232,6 +233,7 @@ module Trino::Client
|
|
232
233
|
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - @started_at
|
233
234
|
|
234
235
|
if @query_timeout && elapsed > @query_timeout
|
236
|
+
close
|
235
237
|
raise_timeout_error!
|
236
238
|
end
|
237
239
|
|
@@ -239,6 +241,7 @@ module Trino::Client
|
|
239
241
|
elapsed > @plan_timeout
|
240
242
|
# @results is not set (even first faraday_get_with_retry isn't called yet) or
|
241
243
|
# result from Trino doesn't include result schema. Query planning isn't done yet.
|
244
|
+
close
|
242
245
|
raise_timeout_error!
|
243
246
|
end
|
244
247
|
end
|
data/lib/trino/client/version.rb
CHANGED
data/trino-client.gemspec
CHANGED
@@ -15,18 +15,22 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
|
18
|
-
gem.required_ruby_version = ">= 2.
|
18
|
+
gem.required_ruby_version = ">= 3.2.0"
|
19
19
|
|
20
20
|
gem.add_dependency "faraday", ">= 1", "< 3"
|
21
21
|
gem.add_dependency "faraday-gzip", ">= 1"
|
22
22
|
gem.add_dependency "faraday-follow_redirects", ">= 0.3"
|
23
23
|
gem.add_dependency "msgpack", [">= 1.5.1"]
|
24
24
|
|
25
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4")
|
26
|
+
gem.add_dependency("base64")
|
27
|
+
end
|
28
|
+
|
25
29
|
gem.add_development_dependency "rake", [">= 0.9.2", "< 14.0"]
|
26
|
-
gem.add_development_dependency "rspec", "~> 3.
|
30
|
+
gem.add_development_dependency "rspec", "~> 3.13.0"
|
27
31
|
gem.add_development_dependency "webmock", ["~> 3.0"]
|
28
32
|
gem.add_development_dependency "addressable", "~> 2.8.1" # 2.5.0 doesn't support Ruby 1.9.3
|
29
33
|
gem.add_development_dependency "simplecov", "~> 0.22.0"
|
30
|
-
gem.add_development_dependency "standard", "~> 1.
|
34
|
+
gem.add_development_dependency "standard", "~> 1.50.0"
|
31
35
|
gem.add_development_dependency "psych", "~> 3"
|
32
36
|
end
|
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.2.
|
4
|
+
version: 2.2.3
|
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: 2025-09-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
|
@@ -154,14 +154,14 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - "~>"
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 1.
|
157
|
+
version: 1.50.0
|
158
158
|
type: :development
|
159
159
|
prerelease: false
|
160
160
|
version_requirements: !ruby/object:Gem::Requirement
|
161
161
|
requirements:
|
162
162
|
- - "~>"
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version: 1.
|
164
|
+
version: 1.50.0
|
165
165
|
- !ruby/object:Gem::Dependency
|
166
166
|
name: psych
|
167
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +183,8 @@ executables: []
|
|
183
183
|
extensions: []
|
184
184
|
extra_rdoc_files: []
|
185
185
|
files:
|
186
|
+
- ".pre-commit-config.yaml"
|
187
|
+
- CLAUDE.md
|
186
188
|
- ChangeLog.md
|
187
189
|
- LICENSE
|
188
190
|
- README.md
|
@@ -218,14 +220,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
220
|
requirements:
|
219
221
|
- - ">="
|
220
222
|
- !ruby/object:Gem::Version
|
221
|
-
version: 2.
|
223
|
+
version: 3.2.0
|
222
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
225
|
requirements:
|
224
226
|
- - ">="
|
225
227
|
- !ruby/object:Gem::Version
|
226
228
|
version: '0'
|
227
229
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.4.19
|
229
231
|
signing_key:
|
230
232
|
specification_version: 4
|
231
233
|
summary: Trino client library
|