forked from influxdata/influxdb-iox-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iox_client_query_test.go
37 lines (33 loc) · 989 Bytes
/
iox_client_query_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
package influxdbiox_test
import (
"context"
"time"
"github.com/apache/arrow/go/v10/arrow/array"
"github.com/influxdata/influxdb-iox-client-go/v2"
)
func ExampleClient_PrepareQuery() {
config, _ := influxdbiox.ClientConfigFromAddressString("localhost:8082")
client, _ := influxdbiox.NewClient(context.Background(), config)
req, _ := client.PrepareQuery(context.Background(), "mydb", "select count(*) from t")
reader, _ := req.Query(context.Background())
for reader.Next() {
record := reader.Record()
for i, column := range record.Columns() {
columnName := record.ColumnName(i)
println(columnName)
switch typedColumn := column.(type) {
case *array.Timestamp:
values := typedColumn.TimestampValues()
for _, value := range values {
var t time.Time = time.Unix(0, int64(value))
println(t.String())
}
case *array.Int64:
var values []int64 = typedColumn.Int64Values()
println(values)
default:
// Unexpected types
}
}
}
}