Skip to content

Commit

Permalink
Merge pull request #41 from ojima-h/raise-error-in-async-execute
Browse files Browse the repository at this point in the history
Raise error when async_execute failed.
  • Loading branch information
robertino committed Nov 23, 2015
2 parents 8d4fdad + c5d7ec5 commit f8a964c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rbhive/t_c_l_i_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,16 @@ def set(name,value)
# Async execute
def async_execute(query)
@logger.info("Executing query asynchronously: #{query}")
op_handle = @client.ExecuteStatement(
exec_result = @client.ExecuteStatement(
Hive2::Thrift::TExecuteStatementReq.new(
sessionHandle: @session.sessionHandle,
statement: query,
runAsync: true
)
).operationHandle

)
raise_error_if_failed!(exec_result)
op_handle = exec_result.operationHandle

# Return handles to get hold of this query / session again
{
session: @session.sessionHandle,
Expand Down Expand Up @@ -236,7 +238,7 @@ def async_state(handles)
response = @client.GetOperationStatus(
Hive2::Thrift::TGetOperationStatusReq.new(operationHandle: prepare_operation_handle(handles))
)
puts response.operationState

case response.operationState
when Hive2::Thrift::TOperationState::FINISHED_STATE
return :finished
Expand Down

0 comments on commit f8a964c

Please sign in to comment.