This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bundle exec rake spec- Run all RSpec testsbundle exec rspec spec/[filename]_spec.rb- Run specific test file
bundle exec rake build- Build the gembundle exec rake- Default task (runs spec and build)
bundle exec standardrb- Run StandardRB linter (code style enforcement)bundle exec standardrb --fix- Auto-fix style issues
bundle exec rake modelgen:latest- Generate model files from latest Trino versionbundle exec rake modelgen:all- Generate all model versions
This is a Ruby client library for Trino (distributed SQL query engine). The architecture is layered:
-
Client Layer (
lib/trino/client/client.rb):Trino::Client::Client- Main API entry point- Provides
run(),run_with_names(),query(),kill()methods - Handles synchronous and streaming query execution
-
Query Layer (
lib/trino/client/query.rb):Queryclass - Manages query execution lifecycle- Handles streaming results via
each_row,each_row_chunk - Provides column metadata and result transformation
-
Statement Client (
lib/trino/client/statement_client.rb):StatementClient- Low-level HTTP communication with Trino- Manages query state machine (running, finished, failed, aborted)
- Handles retries, timeouts, and error conditions
- Supports both JSON and MessagePack response formats
-
HTTP Layer (
lib/trino/client/faraday_client.rb):- Uses Faraday for HTTP requests with middleware for gzip and redirects
- Handles authentication, SSL configuration, proxy settings
-
Versioned Models (
lib/trino/client/model_versions/):- Generated from Trino source code for different Trino versions
- Each version (351, 316, 303, etc.) has its own model definitions
- Default is version 351
-
Model Generation (
modelgen/):- Automated model generation from Trino Java source
- Downloads Trino source and extracts model definitions
- Streaming Results: Query results can be processed row-by-row without loading all data into memory
- Timeout Control: Supports both query-level and plan-level timeouts
- Error Recovery: Built-in retry logic for transient failures (502, 503, 504)
- Multiple Result Formats: Raw arrays, named hashes, or streaming iteration
- ROW Type Support: Can parse Trino ROW types into Ruby hashes via
transform_row
Tests are organized by component:
spec/client_spec.rb- Client API testsspec/statement_client_spec.rb- Low-level protocol testsspec/column_value_parser_spec.rb- Data parsing testsspec/tpch_query_spec.rb- Integration tests with TPC-H queries