Closed gangtao closed 9 months ago
clickhouse support this
package main
import (
"context"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2"
"log"
"time"
)
func example() error {
var (
ctx = context.Background()
conn, err = clickhouse.Open(&clickhouse.Options{
Addr: []string{"127.0.0.1:9000"},
Auth: clickhouse.Auth{
Database: "default",
Username: "default",
Password: "",
},
//Debug: true,
DialTimeout: time.Second,
MaxOpenConns: 10,
MaxIdleConns: 5,
ConnMaxLifetime: time.Hour,
})
)
if err != nil {
return err
}
if err := conn.Exec(ctx, "set allow_experimental_map_type = 1;"); err != nil {
return err
}
if err := conn.Exec(ctx, `DROP TABLE IF EXISTS table_map;`); err != nil {
return err
}
err = conn.Exec(ctx, `
CREATE TABLE table_map (a Map(String, Array(Map(String, Float64)))) ENGINE = Memory;
`)
if err != nil {
return err
}
batch, err := conn.PrepareBatch(ctx, "INSERT INTO table_map")
if err != nil {
return err
}
for i := 0; i < 100; i++ {
err := batch.Append(
map[string][]map[string]float64{
"key1": {
{"sub_key1": 10.9, "sub_key2": float64(i)},
{"sub_key3": float64(i) + 0.1},
},
},
)
if err != nil {
return err
}
}
err = batch.Send()
if err != nil {
return err
}
rows, err := conn.Query(ctx, "SELECT * FROM table_map")
for rows.Next() {
a := &map[string][]map[string]float64{}
err := rows.Scan(a)
if err != nil {
return err
}
fmt.Println(a)
}
if err != nil {
return err
}
return err
}
func main() {
start := time.Now()
if err := example(); err != nil {
log.Fatal(err)
}
fmt.Println(time.Since(start))
}
Yeah, we were too behind the offical clickhouse go driver. It has been years since we rebased. This can be an issue
(Jove Github Bot) added it to the current sprint.
(Jove Github Bot) moved this ticket out of the GitHub project(up to 1200 tickets for one project).
following query can be successfully running on proton but failed to run in neutron.
neutron error is
I think it is because go-driver does not support this complex type as of now, which is required .