Skip to content

Commit

Permalink
Add support for ClickHouse
Browse files Browse the repository at this point in the history
Closes #156
  • Loading branch information
joschi committed Jul 6, 2024
1 parent 3a360f3 commit 06a24f3
Show file tree
Hide file tree
Showing 9 changed files with 643 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root = ture
root = true

[*]
end_of_line = lf
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ db_sqlite:
sqlite3 $(PWD)/testdata/testdb.sqlite3 < testdata/ddl/sqlite.sql

test:
go test ./... -tags 'bq dynamo mariadb mongodb mssql mysql postgres redshift snowflake spanner sqlite' -coverprofile=coverage.out -covermode=count
go test ./... -tags 'bq clickhouse dynamo mariadb mongodb mssql mysql postgres redshift snowflake spanner sqlite' -coverprofile=coverage.out -covermode=count

test-no-db:
go test ./... -coverprofile=coverage.out -covermode=count
Expand Down
4 changes: 4 additions & 0 deletions datasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/k1LoW/go-github-client/v58/factory"
"github.com/k1LoW/tbls/config"
"github.com/k1LoW/tbls/drivers"
"github.com/k1LoW/tbls/drivers/clickhouse"
"github.com/k1LoW/tbls/drivers/mariadb"
"github.com/k1LoW/tbls/drivers/mssql"
"github.com/k1LoW/tbls/drivers/mysql"
Expand Down Expand Up @@ -124,6 +125,9 @@ func Analyze(dsn config.DSN) (*schema.Schema, error) {
case "snowflake":
s.Name = splitted[2]
driver = snowflake.New(db)
case "clickhouse":
s.Name = splitted[1]
driver = clickhouse.New(db)
default:
return s, errors.Errorf("unsupported driver '%s'", u.Driver)
}
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,16 @@ services:
- ./testdata/ddl/mongo:/docker-entrypoint-initdb.d
ports:
- "27017:27017"
clickhouse:
image: clickhouse/clickhouse-server:24.4
restart: always
environment:
- CLICKHOUSE_DB=testdb
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1
volumes:
- ./testdata/ddl/clickhouse:/docker-entrypoint-initdb.d
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8123/?query=SELECT%201 || exit 1
ports:
- "8123:8123"
- "9000:9000"
Loading

0 comments on commit 06a24f3

Please sign in to comment.