Skip to content

Commit

Permalink
feat: adding support for Databend
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored and kenshaw committed Dec 5, 2022
1 parent 032a68a commit f1a45ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ supported out of the box:
| Couchbase (n1ql) | n1, couchbase |
| Cznic QL (ql) | ql, cznic, cznicql |
| CSVQ (csvq) | csv, tsv, json |
| Databend (databend) | bend |
| Exasol (exasol) | ex, exa |
| Firebird SQL (firebirdsql) | fb, firebird |
| Genji (genji) | gj |
Expand Down Expand Up @@ -183,7 +184,7 @@ to be imported:
| Oracle Database (oracle) | [github.com/sijms/go-ora](https://github.com/sijms/go-ora) |
| PostgreSQL (postgres) | [github.com/lib/pq](https://github.com/lib/pq) |
| SQLite3 (sqlite3) | [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) |
| Microsoft SQL Server (sqlserver) | [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb) |
| Microsoft SQL Server (sqlserver) | [github.com/microsoft/go-mssqldb](https://github.com/microsoft/go-mssqldb) |
| | |
| Amazon Redshift (redshift) | [github.com/lib/pq](https://github.com/lib/pq) |
| CockroachDB (cockroachdb) | [github.com/lib/pq](https://github.com/lib/pq) |
Expand All @@ -209,6 +210,7 @@ to be imported:
| Couchbase (n1ql) | [github.com/couchbase/go_n1ql](https://github.com/couchbase/go_n1ql) |
| Cznic QL (ql) | [modernc.org/ql](https://modernc.org/ql) |
| CSVQ (csvq) | [github.com/mithrandie/csvq](https://github.com/mithrandie/csvq) |
| Databend (databend) | [github.com/databendcloud/databend-go](https://github.com/databendcloud/databend-go) |
| Exasol (exasol) | [github.com/exasol/exasol-driver-go](https://github.com/exasol/exasol-driver-go) |
| Firebird SQL (firebirdsql) | [github.com/nakagami/firebirdsql](https://github.com/nakagami/firebirdsql) |
| Genji (genji) | [github.com/genjidb/genji/sql/driver](https://github.com/genjidb/genji) |
Expand Down
6 changes: 4 additions & 2 deletions dburl.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
// Oracle (godror) | gr
// ---------------------------------|--------------------------------------------
// Alibaba MaxCompute (maxcompute) | mc
// Alibaba Tablestore (ots) | ot, ots, tablestore
// Alibaba Tablestore (ots) | ot, ots, tablestore
// Apache Avatica (avatica) | av, phoenix
// Apache H2 (h2) | h2
// Apache Hive (hive) | hi
Expand All @@ -101,7 +101,8 @@
// Couchbase (n1ql) | n1, couchbase
// Cznic QL (ql) | ql, cznic, cznicql
// CSVQ (csvq) | csv, tsv, json
// Exasol (exasol | ex, exa
// Exasol (exasol) | ex, exa
// Databend (databend) | bend
// Firebird SQL (firebirdsql) | fb, firebird
// Genji (genji) | gj
// Google BigQuery (bigquery) | bq
Expand Down Expand Up @@ -162,6 +163,7 @@
// Couchbase (n1ql) | github.com/couchbase/go_n1ql
// Cznic QL (ql) | modernc.org/ql
// CSVQ (csvq) | github.com/mithrandie/csvq
// Databend (databend) | github.com/datafuselabs/databend
// Exasol (exasol) | github.com/exasol/exasol-driver-go
// Firebird SQL (firebirdsql) | github.com/nakagami/firebirdsql
// Genji (genji) | github.com/genjidb/genji/sql/driver
Expand Down
4 changes: 4 additions & 0 deletions dburl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestBadParse(t *testing.T) {
{`mq+tcp://`, ErrInvalidTransportProtocol},
{`ots+tcp://`, ErrInvalidTransportProtocol},
{`tablestore+tcp://`, ErrInvalidTransportProtocol},
{`bend://`, ErrMissingHost},
{`databend://`, ErrMissingHost},
}
for i, test := range tests {
_, err := Parse(test.s)
Expand Down Expand Up @@ -199,6 +201,8 @@ func TestParse(t *testing.T) {
{`tablestore://user:pass@localhost/instance_name`, `ots`, `https://user:pass@localhost/instance_name`, ``},
{`tablestore+https://user:pass@localhost/instance_name`, `ots`, `https://user:pass@localhost/instance_name`, ``},
{`tablestore+http://user:pass@localhost/instance_name`, `ots`, `http://user:pass@localhost/instance_name`, ``},
{`bend://user:pass@localhost/instance_name?sslmode=disabled&warehouse=wh`, `databend`, `bend://user:pass@localhost/instance_name?sslmode=disabled&warehouse=wh`, ``},
{`databend://user:pass@localhost/instance_name?tenant=tn&warehouse=wh`, `databend`, `databend://user:pass@localhost/instance_name?tenant=tn&warehouse=wh`, ``},
}
for i, test := range tests {
u, err := Parse(test.s)
Expand Down
8 changes: 8 additions & 0 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ func GenCosmos(u *URL) (string, error) {
return genOptionsOdbc(q, true), nil
}

// GenDatabend generates a databend DSN from the passed URL.
func GenDatabend(u *URL) (string, error) {
if u.Hostname() == "" {
return "", ErrMissingHost
}
return u.String(), nil
}

// GenExasol generates a exasol DSN from the passed URL.
func GenExasol(u *URL) (string, error) {
host, port, dbname := u.Hostname(), u.Port(), strings.TrimPrefix(u.Path, "/")
Expand Down
1 change: 1 addition & 0 deletions scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func BaseSchemes() []Scheme {
{"cosmos", GenCosmos, 0, false, []string{"cm"}, ""},
{"cql", GenCassandra, 0, false, []string{"ca", "cassandra", "datastax", "scy", "scylla"}, ""},
{"csvq", GenOpaque, 0, true, []string{"csv", "tsv", "json"}, ""},
{"databend", GenDatabend, 0, false, []string{"bend"}, ""},
{"exasol", GenExasol, 0, false, []string{"ex", "exa"}, ""},
{"firebirdsql", GenFirebird, 0, false, []string{"fb", "firebird"}, ""},
{"genji", GenOpaque, 0, true, []string{"gj"}, ""},
Expand Down

0 comments on commit f1a45ca

Please sign in to comment.