Skip to content

Commit 1a0e975

Browse files
authored
misc: Add CLAUDE.md and etc (#138)
* Add CLAUDE.md * Add .pre-commit-config.yaml
1 parent a0710db commit 1a0e975

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Example:
1515
- [ ] Code compiles correctly
1616
- [ ] Created tests which fail without the change (if possible)
1717
- [ ] All tests passing
18-
- [ ] Extended the README / documentation, if necessary
18+
- [ ] Extended the README / documentation, if necessary

.github/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ autolabeler:
4242
- '/fix/i'
4343
- label: 'deprecation'
4444
title:
45-
- '/deprecate/i'
45+
- '/deprecate/i'

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

CLAUDE.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)