Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add ClickHouse database engine support
Add ClickHouse support using the github.com/sqlc-dev/doubleclick parser library.

New files in internal/engine/clickhouse/:
- parse.go: Parser implementation using doubleclick
- convert.go: AST converter from doubleclick to sqlc AST
- format.go: ClickHouse-specific SQL formatting
- catalog.go: Catalog initialization
- stdlib.go: Standard library functions
- reserved.go: Reserved keywords
- utils.go: Helper functions
- parse_test.go: Unit tests

Supported SQL operations:
- SELECT with JOINs, subqueries, CTEs, window functions
- INSERT with VALUES and SELECT subquery
- UPDATE and DELETE
- CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE

Co-Authored-By: Claude <noreply@anthropic.com>
  • Loading branch information
kyleconroy and claude committed Jan 17, 2026
commit c215af286f19ef33800684b32b7af8ba83776907
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/sqlc-dev/sqlc

go 1.24.0

toolchain go1.24.1
go 1.24.7

require (
github.com/antlr4-go/antlr/v4 v4.13.1
Expand Down Expand Up @@ -48,6 +46,7 @@ require (
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/log v1.1.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/sqlc-dev/doubleclick v1.0.0 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/sqlc-dev/doubleclick v1.0.0 h1:2/OApfQ2eLgcfa/Fqs8WSMA6atH0G8j9hHbQIgMfAXI=
github.com/sqlc-dev/doubleclick v1.0.0/go.mod h1:ODHRroSrk/rr5neRHlWMSRijqOak8YmNaO3VAZCNl5Y=
github.com/sqlc-dev/mysql v0.0.0-20251129233104-d81e1cac6db2 h1:kmCAKKtOgK6EXXQX9oPdEASIhgor7TCpWxD8NtcqVcU=
github.com/sqlc-dev/mysql v0.0.0-20251129233104-d81e1cac6db2/go.mod h1:TrDMWzjNTKvJeK2GC8uspG+PWyPLiY9QKvwdWpAdlZE=
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
Expand Down
5 changes: 5 additions & 0 deletions internal/compiler/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/sqlc-dev/sqlc/internal/analyzer"
"github.com/sqlc-dev/sqlc/internal/config"
"github.com/sqlc-dev/sqlc/internal/dbmanager"
"github.com/sqlc-dev/sqlc/internal/engine/clickhouse"
"github.com/sqlc-dev/sqlc/internal/engine/dolphin"
"github.com/sqlc-dev/sqlc/internal/engine/postgresql"
pganalyze "github.com/sqlc-dev/sqlc/internal/engine/postgresql/analyzer"
Expand Down Expand Up @@ -82,6 +83,10 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings, parserOpts opts
c.parser = dolphin.NewParser()
c.catalog = dolphin.NewCatalog()
c.selector = newDefaultSelector()
case config.EngineClickHouse:
c.parser = clickhouse.NewParser()
c.catalog = clickhouse.NewCatalog()
c.selector = newDefaultSelector()
case config.EnginePostgreSQL:
parser := postgresql.NewParser()
c.parser = parser
Expand Down
7 changes: 4 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

const (
EngineMySQL Engine = "mysql"
EnginePostgreSQL Engine = "postgresql"
EngineSQLite Engine = "sqlite"
EngineMySQL Engine = "mysql"
EnginePostgreSQL Engine = "postgresql"
EngineSQLite Engine = "sqlite"
EngineClickHouse Engine = "clickhouse"
)

type Config struct {
Expand Down
16 changes: 16 additions & 0 deletions internal/engine/clickhouse/catalog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package clickhouse

import (
"github.com/sqlc-dev/sqlc/internal/sql/catalog"
)

func NewCatalog() *catalog.Catalog {
def := "default" // ClickHouse default database
return &catalog.Catalog{
DefaultSchema: def,
Schemas: []*catalog.Schema{
defaultSchema(def),
},
Extensions: map[string]struct{}{},
}
}
Loading
Loading