Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(clickhouse): add ClickHouse database engine support #4244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kyleconroy wants to merge 7 commits into main
base: main
Choose a base branch
Loading
from claude/add-clickhouse-support-3cSUA

Conversation

@kyleconroy
Copy link
Collaborator

@kyleconroy kyleconroy commented Dec 24, 2025

Add initial ClickHouse support with the following components:

  • Parser using sqlc-dev/doubleclick to parse ClickHouse SQL
  • Analyzer for database-only mode (requires live database connection)
  • Go codegen with ClickHouse type mappings
  • Docker and native sqltest support
  • End-to-end test case with authors table example

The implementation requires the clickhouse experiment flag
(SQLCEXPERIMENT=clickhouse) and database-only analyzer mode
(analyzer.database: only) since static analysis is not yet supported.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Maksim963 reacted with rocket emoji
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. 🔧 golang labels Dec 24, 2025
Add initial ClickHouse support with the following components:
- Parser using sqlc-dev/doubleclick to parse ClickHouse SQL
- Analyzer for database-only mode (requires live database connection)
- Go codegen with ClickHouse type mappings
- Docker and native sqltest support
- End-to-end test case with authors table example
The implementation requires the clickhouse experiment flag
(SQLCEXPERIMENT=clickhouse) and database-only analyzer mode
(analyzer.database: only) since static analysis is not yet supported.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
...ntation
Key fixes:
- Fix 1-indexed offset from doubleclick parser to 0-indexed for sqlc
- Include comment lines in statement extraction for metadata parsing
- Calculate StmtLen correctly by finding semicolon positions
- Replace ? placeholders with NULL for database introspection
- Skip INSERT/UPDATE/DELETE queries when getting column info (no return cols)
- Pass experiment flag through process.go and vet.go
- Remove trailing semicolons before appending LIMIT 0 for introspection
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
...puts
This commit fixes two issues:
1. ClickHouse end-to-end tests: Changed from managed-db context to a new
 clickhouse-specific context. The managed-db context only handles
 PostgreSQL, MySQL, and SQLite. ClickHouse tests now only run when
 a ClickHouse database is available.
2. AnalyzerV2 test outputs: The Experiment flag was not being passed to
 parseOpts in process.go and vet.go. This meant the AnalyzerV2 experiment
 was never actually active, even when tests configured SQLCEXPERIMENT.
 Now that the experiment is properly passed, the test expected outputs
 have been regenerated to match actual AnalyzerV2 behavior.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
...ntext
- Update CLAUDE.md with ClickHouse installation instructions using official
 repository (Ubuntu packages have incompatible old version)
- Add ClickHouse test context to endtoend_test.go with schema migration support
- Import clickhouse-go v2 driver and database/sql for test context
- Add test filtering to only run ClickHouse tests under clickhouse context
- Add generated test output files for clickhouse_authors test case
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
@kyleconroy kyleconroy force-pushed the claude/add-clickhouse-support-3cSUA branch from 3252e80 to ff082bd Compare December 24, 2025 16:40
- Update ClickHouse to use managed-db context instead of separate context
- Fix detectParameters to count ? placeholders in addition to parsing
 {name:Type} style parameters with doubleclick parser
- Add DROP TABLE IF EXISTS before CREATE TABLE in migrations for
 idempotent schema application
- Set ClickHouse database URI in test config for proper connection
- Add pgrep check for MySQL service detection in native tests
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update ClickHouse test queries to use {name:Type} parameter syntax
 instead of ? placeholders for better type inference
- Add regex-based parameter detection for named parameters
- Add replaceParamsWithNull helper to handle named params in DESCRIBE
- Set NotNull: true for parameters to generate non-nullable Go types
- Remove unused AST walking code that was replaced by regex approach
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace regex-based parameter detection with AST walking using the
doubleclick parser. This avoids issues with parameters in comments
being incorrectly detected.
For INSERT VALUES clauses (which doubleclick doesn't fully parse),
extract the VALUES content and parse it as a SELECT to properly
detect parameters through AST walking.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files. 🔧 golang

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /