Skip to content
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

Add support for ClickHouse #605

Merged
merged 3 commits into from
Jul 9, 2024
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
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
joschi marked this conversation as resolved.
Show resolved Hide resolved

[*]
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