Impalathing is a small Go wrapper library the thrift interface go Impala
It's based on hivething
Working on this you quickly realize that having strings deliminated by tabs is a ugly API... (That's the thrift side of things)
package main
import (
"log"
"fmt"
"time"
"github.com/koblas/impalathing"
)
func main() {
host := "impala-host"
port := 21000
con, err := impalathing.Connect(host, port, impalathing.DefaultOptions)
if err != nil {
log.Fatal("Error connecting", err)
return
}
query, err := con.Query("SELECT user_id, action, yyyymm FROM engagements LIMIT 10000")
startTime := time.Now()
total := 0
for query.Next() {
var (
user_id string
action string
yyyymm int
)
query.Scan(&user_id, &action, &yyyymm)
total += 1
fmt.Println(user_id, action)
}
log.Printf("Fetch %d rows(s) in %.2fs", total, time.Duration(time.Since(startTime)).Seconds())
}
NOTES: changes for MediaMath:
* there are a few updates and improvements in connection and rowset:
- fix connection leaks
- fix rowset metadata
* interfaces are from whatver impala build we are using (currently 3.0.1)
* interfaces are edited to build thrift interfaces for Go. In particular we need to work around list (in go []slice) map keys, which are
not valid Go. For now I have manually removed an optional member struct: SkewedInfo