Created
October 26, 2020 03:09
-
-
Save lilinghai/c21c606932a2e919605ce642ef076c37 to your computer and use it in GitHub Desktop.
reproduce the gohive issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gohive 的问题是啥