forked from segmentio/go-athena
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrows.go
47 lines (41 loc) · 911 Bytes
/
rows.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
package athena
import (
"database/sql/driver"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/athena/athenaiface"
)
type rowsConfig struct {
Athena athenaiface.AthenaAPI
QueryID string
SkipHeader bool
ResultMode ResultMode
Session *session.Session
OutputLocation string
Timeout uint
AfterDownload func() error
CTASTable string
DB string
Catalog string
}
type downloadedRows struct {
cursor int
data [][]string // for gzip dl
field [][]downloadField // for csv dl
}
type downloadField struct {
val string
isNil bool
}
func newRows(cfg rowsConfig) (driver.Rows, error) {
var r driver.Rows
var err error
switch cfg.ResultMode {
case ResultModeDL:
r, err = newRowsDL(cfg)
case ResultModeGzipDL:
r, err = newRowsGzipDL(cfg)
default:
r, err = newRowsAPI(cfg)
}
return r, err
}