Jelajahi Sumber

HUE-2095 [beeswax] Do not fetch statements without a resultset

HiveServer2 in 0.13 raises an exception if we call fetch result on
a statement without a resultset.
Romain Rigaux 11 tahun lalu
induk
melakukan
03b82fc
1 mengubah file dengan 6 tambahan dan 3 penghapusan
  1. 6 3
      apps/beeswax/src/beeswax/server/hive_server2_lib.py

+ 6 - 3
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -29,7 +29,7 @@ from TCLIService.ttypes import TOpenSessionReq, TGetTablesReq, TFetchResultsReq,
   TStatusCode, TGetResultSetMetadataReq, TGetColumnsReq, TTypeId,\
   TExecuteStatementReq, TGetOperationStatusReq, TFetchOrientation,\
   TCloseSessionReq, TGetSchemasReq, TGetLogReq, TCancelOperationReq,\
-  TCloseOperationReq
+  TCloseOperationReq, TFetchResultsResp, TRowSet
 
 from beeswax import conf as beeswax_conf
 from beeswax import hive_site
@@ -548,8 +548,11 @@ class HiveServerClient:
 
 
   def fetch_result(self, operation_handle, orientation=TFetchOrientation.FETCH_NEXT, max_rows=1000):
-    fetch_req = TFetchResultsReq(operationHandle=operation_handle, orientation=orientation, maxRows=max_rows)
-    res = self.call(self._client.FetchResults, fetch_req)
+    if operation_handle.hasResultSet:
+      fetch_req = TFetchResultsReq(operationHandle=operation_handle, orientation=orientation, maxRows=max_rows)
+      res = self.call(self._client.FetchResults, fetch_req)
+    else:
+      res = TFetchResultsResp(results=TRowSet(startRowOffset=0, rows=[], columns=[]))
 
     if operation_handle.hasResultSet:
       meta_req = TGetResultSetMetadataReq(operationHandle=operation_handle)