Skip to content

Commit

Permalink
Add FetchLogs function
Browse files Browse the repository at this point in the history
  • Loading branch information
eveninglily committed Feb 25, 2021
1 parent fa369a2 commit 5f0bf05
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions hive.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,34 @@ func (c *Cursor) Poll(getProgress bool) (status *hiveserver.TGetOperationStatusR
return responsePoll
}

// FetchLogs returns all the Hive execution logs for the latest query up to the current point
func (c *Cursor) FetchLogs() []string {
logRequest := hiveserver.NewTFetchResultsReq()
logRequest.OperationHandle = c.operationHandle
logRequest.Orientation = hiveserver.TFetchOrientation_FETCH_NEXT
logRequest.MaxRows = c.conn.configuration.FetchSize
// FetchType 1 is "logs"
logRequest.FetchType = 1

resp, err := c.conn.client.FetchResults(context.Background(), logRequest)
if err != nil {
return nil
}

// resp contains 1 row, with a column for each line in the log
cols := resp.Results.GetColumns()
var logs []string

for i := 0; i < len(cols); i++ {
col := cols[i].StringVal.Values
for j := 0; j < len(col); j++ {
logs = append(logs, col[j])
}
}

return logs
}

// Finished returns true if the last async operation has finished
func (c *Cursor) Finished() bool {
operationStatus := c.Poll(true)
Expand Down

0 comments on commit 5f0bf05

Please sign in to comment.