-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (52 loc) · 1.23 KB
/
main.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
package main
import (
"context"
"fmt"
driver "github.com/apache/arrow-adbc/go/adbc/driver/bigquery"
"github.com/apache/arrow-go/v18/arrow/memory"
)
const (
PROJECT_ID = ""
DATASET_ID = "abc"
)
// arrow-adbc/go/adbc/driver/bigquery/driver_test.go
func main() {
ctx := context.Background()
mem := memory.NewCheckedAllocator(memory.DefaultAllocator)
t := driver.NewDriver(mem)
options := map[string]string{
driver.OptionStringProjectID: PROJECT_ID,
driver.OptionStringDatasetID: DATASET_ID,
}
db, err := t.NewDatabase(options)
if err != nil {
panic(err)
}
defer db.Close()
cnxn, err := db.Open(ctx)
if err != nil {
panic(err)
}
defer cnxn.Close()
stmt, err := cnxn.NewStatement()
if err != nil {
panic(err)
}
defer stmt.Close()
err = stmt.SetOption(driver.OptionBoolQueryUseLegacySQL, "false")
if err != nil {
panic(err)
}
query := "drop schema abc cascade"
err = stmt.SetSqlQuery(query)
if err != nil {
panic(err)
}
rdr, _, err := stmt.ExecuteQuery(ctx)
if err != nil {
panic(err)
}
defer rdr.Release()
fmt.Println(rdr.Schema().NumFields())
fmt.Printf("done\n")
}