Skip to content
This repository was archived by the owner on Sep 23, 2020. It is now read-only.

Commit f8a964c

Browse files
committed
Merge pull request forward3d#41 from ojima-h/raise-error-in-async-execute
Raise error when async_execute failed.
2 parents 8d4fdad + c5d7ec5 commit f8a964c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/rbhive/t_c_l_i_connection.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ def set(name,value)
192192
# Async execute
193193
def async_execute(query)
194194
@logger.info("Executing query asynchronously: #{query}")
195-
op_handle = @client.ExecuteStatement(
195+
exec_result = @client.ExecuteStatement(
196196
Hive2::Thrift::TExecuteStatementReq.new(
197197
sessionHandle: @session.sessionHandle,
198198
statement: query,
199199
runAsync: true
200200
)
201-
).operationHandle
202-
201+
)
202+
raise_error_if_failed!(exec_result)
203+
op_handle = exec_result.operationHandle
204+
203205
# Return handles to get hold of this query / session again
204206
{
205207
session: @session.sessionHandle,
@@ -236,7 +238,7 @@ def async_state(handles)
236238
response = @client.GetOperationStatus(
237239
Hive2::Thrift::TGetOperationStatusReq.new(operationHandle: prepare_operation_handle(handles))
238240
)
239-
puts response.operationState
241+
240242
case response.operationState
241243
when Hive2::Thrift::TOperationState::FINISHED_STATE
242244
return :finished

0 commit comments

Comments
 (0)