Skip to content

Commit 4b880fd

Browse files
kyleconroyclaude
andcommitted
refactor: move ClickHouse support to parse command only
Remove ClickHouse from compiler/engine.go and config.go. Add --dialect clickhouse support to the sqlc parse command. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dbd5583 commit 4b880fd

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

internal/cmd/parse.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/spf13/cobra"
1010

11+
"github.com/sqlc-dev/sqlc/internal/engine/clickhouse"
1112
"github.com/sqlc-dev/sqlc/internal/engine/dolphin"
1213
"github.com/sqlc-dev/sqlc/internal/engine/postgresql"
1314
"github.com/sqlc-dev/sqlc/internal/engine/sqlite"
@@ -27,15 +28,18 @@ Examples:
2728
echo "SELECT * FROM users" | sqlc parse --dialect mysql
2829
2930
# Parse SQLite SQL
30-
sqlc parse --dialect sqlite queries.sql`,
31+
sqlc parse --dialect sqlite queries.sql
32+
33+
# Parse ClickHouse SQL
34+
sqlc parse --dialect clickhouse queries.sql`,
3135
Args: cobra.MaximumNArgs(1),
3236
RunE: func(cmd *cobra.Command, args []string) error {
3337
dialect, err := cmd.Flags().GetString("dialect")
3438
if err != nil {
3539
return err
3640
}
3741
if dialect == "" {
38-
return fmt.Errorf("--dialect flag is required (postgresql, mysql, or sqlite)")
42+
return fmt.Errorf("--dialect flag is required (postgresql, mysql, sqlite, or clickhouse)")
3943
}
4044

4145
// Determine input source
@@ -71,8 +75,11 @@ Examples:
7175
case "sqlite":
7276
parser := sqlite.NewParser()
7377
stmts, err = parser.Parse(input)
78+
case "clickhouse":
79+
parser := clickhouse.NewParser()
80+
stmts, err = parser.Parse(input)
7481
default:
75-
return fmt.Errorf("unsupported dialect: %s (use postgresql, mysql, or sqlite)", dialect)
82+
return fmt.Errorf("unsupported dialect: %s (use postgresql, mysql, sqlite, or clickhouse)", dialect)
7683
}
7784
if err != nil {
7885
return fmt.Errorf("parse error: %w", err)

internal/compiler/engine.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/sqlc-dev/sqlc/internal/analyzer"
88
"github.com/sqlc-dev/sqlc/internal/config"
99
"github.com/sqlc-dev/sqlc/internal/dbmanager"
10-
"github.com/sqlc-dev/sqlc/internal/engine/clickhouse"
1110
"github.com/sqlc-dev/sqlc/internal/engine/dolphin"
1211
"github.com/sqlc-dev/sqlc/internal/engine/postgresql"
1312
pganalyze "github.com/sqlc-dev/sqlc/internal/engine/postgresql/analyzer"
@@ -83,10 +82,6 @@ func NewCompiler(conf config.SQL, combo config.CombinedSettings, parserOpts opts
8382
c.parser = dolphin.NewParser()
8483
c.catalog = dolphin.NewCatalog()
8584
c.selector = newDefaultSelector()
86-
case config.EngineClickHouse:
87-
c.parser = clickhouse.NewParser()
88-
c.catalog = clickhouse.NewCatalog()
89-
c.selector = newDefaultSelector()
9085
case config.EnginePostgreSQL:
9186
parser := postgresql.NewParser()
9287
c.parser = parser

internal/config/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error {
5151
}
5252

5353
const (
54-
EngineMySQL Engine = "mysql"
55-
EnginePostgreSQL Engine = "postgresql"
56-
EngineSQLite Engine = "sqlite"
57-
EngineClickHouse Engine = "clickhouse"
54+
EngineMySQL Engine = "mysql"
55+
EnginePostgreSQL Engine = "postgresql"
56+
EngineSQLite Engine = "sqlite"
5857
)
5958

6059
type Config struct {

0 commit comments

Comments
 (0)