-
Notifications
You must be signed in to change notification settings - Fork 53
/
example_test.go
42 lines (37 loc) · 1.01 KB
/
example_test.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
package ch
import (
"fmt"
"time"
"github.com/ClickHouse/ch-go/proto"
)
func ExampleQuery_multipleInputColumns() {
var (
body proto.ColStr
name proto.ColStr
sevText proto.ColEnum
sevNumber proto.ColUInt8
ts = new(proto.ColDateTime64).WithPrecision(proto.PrecisionNano)
arr = new(proto.ColStr).Array() // Array(String)
now = time.Date(2010, 1, 1, 10, 22, 33, 345678, time.UTC)
)
// Append 10 rows.
for i := 0; i < 10; i++ {
body.AppendBytes([]byte("Hello"))
ts.Append(now)
name.Append("name")
sevText.Values = append(sevText.Values, "INFO")
sevNumber = append(sevNumber, 10)
arr.Append([]string{"foo", "bar", "baz"})
}
input := proto.Input{
{Name: "ts", Data: ts},
{Name: "severity_text", Data: &sevText},
{Name: "severity_number", Data: sevNumber},
{Name: "body", Data: body},
{Name: "name", Data: name},
{Name: "arr", Data: arr},
}
fmt.Println(input.Into("logs"))
// Output:
// INSERT INTO "logs" ("ts","severity_text","severity_number","body","name","arr") VALUES
}