-
Notifications
You must be signed in to change notification settings - Fork 111
/
druid.go
69 lines (54 loc) · 1.55 KB
/
druid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package druid
import (
"context"
"github.com/jmoiron/sqlx"
"github.com/rilldata/rill/runtime/drivers"
"go.uber.org/zap"
// Load calcite avatica driver for druid
_ "github.com/apache/calcite-avatica-go/v5"
)
func init() {
drivers.Register("druid", driver{})
}
type driver struct{}
// Open connects to Druid using Avatica.
// Note that the Druid connection string must have the form "http://host/druid/v2/sql/avatica-protobuf/".
func (d driver) Open(dsn string, logger *zap.Logger) (drivers.Connection, error) {
db, err := sqlx.Open("avatica", dsn)
if err != nil {
return nil, err
}
conn := &connection{db: db}
return conn, nil
}
type connection struct {
db *sqlx.DB
}
// Close implements drivers.Connection.
func (c *connection) Close() error {
return c.db.Close()
}
// Registry implements drivers.Connection.
func (c *connection) RegistryStore() (drivers.RegistryStore, bool) {
return nil, false
}
// Catalog implements drivers.Connection.
func (c *connection) CatalogStore() (drivers.CatalogStore, bool) {
return nil, false
}
// Repo implements drivers.Connection.
func (c *connection) RepoStore() (drivers.RepoStore, bool) {
return nil, false
}
// OLAP implements drivers.Connection.
func (c *connection) OLAPStore() (drivers.OLAPStore, bool) {
return c, true
}
// Migrate implements drivers.Connection.
func (c *connection) Migrate(ctx context.Context) (err error) {
return nil
}
// MigrationStatus implements drivers.Connection.
func (c *connection) MigrationStatus(ctx context.Context) (current, desired int, err error) {
return 0, 0, nil
}