-
Notifications
You must be signed in to change notification settings - Fork 40
/
rows.go
44 lines (36 loc) · 975 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
package impala
import (
"database/sql/driver"
"reflect"
"github.com/bippio/go-impala/hive"
)
// Rows is an iterator over an executed query's results.
type Rows struct {
rs *hive.ResultSet
schema *hive.TableSchema
closefn func() error
}
// Close closes rows iterator
func (r *Rows) Close() error {
return r.closefn()
}
// Columns returns the names of the columns
func (r *Rows) Columns() []string {
var cols []string
for _, col := range r.schema.Columns {
cols = append(cols, col.Name)
}
return cols
}
// ColumnTypeScanType returns column's native type
func (r *Rows) ColumnTypeScanType(index int) reflect.Type {
return r.schema.Columns[index].ScanType
}
// ColumnTypeDatabaseTypeName returns column's database type name
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string {
return r.schema.Columns[index].DatabaseTypeName
}
// Next prepares next row for scanning
func (r *Rows) Next(dest []driver.Value) error {
return r.rs.Next(dest)
}