I use https://github.com/apache/hive/blob/trunk/service/if/TCLIService.thrift to gen golang sdk, but it ddn't work. The golang sdk can only opensession. I compare my code within python sdk and didn't find any error usage. below is my golang code.
socket, err := thrift.NewTSocket("localhost:11000")
if err != nil {
fmt.Printf("%s
", err)
return
}
trans := thrift.NewTBufferedTransport(socket, 1024)
protocol := thrift.NewTBinaryProtocol(trans, true, true)
client := hive.NewTCLIServiceClientProtocol(trans, protocol, protocol)
trans.Open()
defer trans.Close()
sReq := hive.NewTOpenSessionReq()
sReq.ClientProtocol = 0
session, err := client.OpenSession(sReq)
fmt.Printf("!%#v %s
", session, err)
exeReq := hive.NewTExecuteStatementReq()
exeReq.SessionHandle = session.SessionHandle
exeReq.Statement = "USE default"
result, err := client.ExecuteStatement(exeReq)
fmt.Printf("result: %s !! %s
", result, err)
and the output is :
!&hive.TOpenSessionResp{Status:(*hive.TStatus)(0xc21001e460), ServerProtocolVersion:0, SessionHandle:(*hive.TSessionHandle)(0xc2100002b0), Configuration:map[string]string{}} %!s(<nil>)
result: <nil> !! Required field 'guid' is unset! Struct:THandleIdentifier(guid:null, secret:null)
Required field 'guid' is unset! Struct:THandleIdentifier(guid:null, secret:null) is return by the server. I have try other hive functions, always the same error.
Is there something wrong with my code or thirft didn't support golang yet?