for more information on golang hive driver, please refer https://github.com/beltran/gohive
create table test (id int);
insert into table test values (1),(2),(3),(4),(5);
select * from test;
1
2
3
4
5
package main
import (
"context"
"fmt"
"github.com/beltran/gohive"
"log"
)
func main() {
conf := gohive.NewConnectConfiguration()
conn, err := gohive.Connect("hdp31ab",10500,"NONE",conf)
if err != nil {
log.Fatal("Error occured while getting the connection %v ",err)
}
defer conn.Close()
cur := conn.Cursor()
defer cur.Close()
cur.Exec(context.Background(),"select * from test")
if cur.Err != nil {
log.Fatal("unable to get the result set from hive server : %v",cur.Err)
}
ctx := context.Background()
var rowcell1 int32
for cur.HasMore(ctx){
cur.FetchOne(ctx, &rowcell1)
fmt.Println(rowcell1)
}
}
go run hiveclient.go
1
2
3
4
5