Skip to content

Instantly share code, notes, and snippets.

@lilinghai
Created October 26, 2020 03:09
Show Gist options
  • Save lilinghai/c21c606932a2e919605ce642ef076c37 to your computer and use it in GitHub Desktop.
Save lilinghai/c21c606932a2e919605ce642ef076c37 to your computer and use it in GitHub Desktop.
reproduce the gohive issue
1.start thriftserver
./sbin/start-thriftserver.sh
2.go hive program
package main
import (
"context"
"github.com/beltran/gohive"
"log"
)
func main() {
ctx := context.Background()
configuration := gohive.NewConnectConfiguration()
//Beeline will ask you for a username and password. In non-secure mode, simply enter the username on your machine and a blank password
configuration.Username = "llh"
configuration.Database = "default"
connection, errConn := gohive.Connect("192.168.228.4", 10000, "NONE", configuration)
if errConn != nil {
log.Fatal(errConn)
}
cursor := connection.Cursor()
cursor.Exec(ctx,"drop table if exists t")
cursor.Exec(ctx,"create table t(a int,b int)")
cursor.Exec(ctx,"insert into t values(1,2)")
cursor.Exec(ctx, "select * from t as x left join t as y on x.a=y.b")
if cursor.Err != nil {
log.Fatal(cursor.Err)
}
desc := cursor.Description()
log.Println(desc)
for cursor.HasMore(ctx) {
row := cursor.RowMap(ctx)
log.Println(row)
}
cursor.Close()
connection.Close()
}
3. pyhive program
from pyhive import hive
conn = hive.connect(host="192.168.228.4", port=10000, username="llh")
cursor = conn.cursor()
cursor.execute("use default")
cursor.execute("drop table if exists t")
cursor.execute("create table t(a int,b int)")
cursor.execute("insert into t values(1,2)")
cursor.execute("select * from t as x left join t as y on x.a=y.b")
print(cursor.fetchall())
4. beeline
./bin/beeline
!connect jdbc:hive2://localhost:10000
execute sql...
@alingse
Copy link

alingse commented Jul 16, 2021

gohive 的问题是啥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment