mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix hive.fetch_logs (#2968)
This commit is contained in:
parent
0ec9cd4ad2
commit
6045063e78
@ -723,9 +723,9 @@ class HiveEngineSpec(PrestoEngineSpec):
|
|||||||
cursor.cancel()
|
cursor.cancel()
|
||||||
break
|
break
|
||||||
|
|
||||||
resp = cursor.fetch_logs()
|
logs = cursor.fetch_logs()
|
||||||
if resp and resp.log:
|
if logs:
|
||||||
progress = cls.progress(resp.log)
|
progress = cls.progress(logs)
|
||||||
if progress > query.progress:
|
if progress > query.progress:
|
||||||
query.progress = progress
|
query.progress = progress
|
||||||
session.commit()
|
session.commit()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from pyhive import hive
|
from pyhive import hive
|
||||||
from pythrifthiveapi.TCLIService import ttypes
|
from pythrifthiveapi.TCLIService import ttypes
|
||||||
|
from thrift import Thrift
|
||||||
|
|
||||||
|
|
||||||
# TODO: contribute back to pyhive.
|
# TODO: contribute back to pyhive.
|
||||||
@ -15,9 +16,11 @@ def fetch_logs(self, max_rows=1024,
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
req = ttypes.TGetLogReq(operationHandle=self._operationHandle)
|
req = ttypes.TGetLogReq(operationHandle=self._operationHandle)
|
||||||
logs = self._connection.client.GetLog(req)
|
logs = self._connection.client.GetLog(req).log
|
||||||
return logs
|
return logs
|
||||||
except ttypes.TApplicationException as e: # raised if Hive is used
|
# raised if Hive is used
|
||||||
|
except (ttypes.TApplicationException,
|
||||||
|
Thrift.TApplicationException):
|
||||||
if self._state == self._STATE_NONE:
|
if self._state == self._STATE_NONE:
|
||||||
raise hive.ProgrammingError("No query yet")
|
raise hive.ProgrammingError("No query yet")
|
||||||
logs = []
|
logs = []
|
||||||
@ -30,12 +33,11 @@ def fetch_logs(self, max_rows=1024,
|
|||||||
)
|
)
|
||||||
response = self._connection.client.FetchResults(req)
|
response = self._connection.client.FetchResults(req)
|
||||||
hive._check_status(response)
|
hive._check_status(response)
|
||||||
assert not (
|
assert not response.results.rows, \
|
||||||
response.results.rows, 'expected data in columnar format'
|
'expected data in columnar format'
|
||||||
)
|
|
||||||
assert len(response.results.columns) == 1, response.results.columns
|
assert len(response.results.columns) == 1, response.results.columns
|
||||||
new_logs = hive._unwrap_column(response.results.columns[0])
|
new_logs = hive._unwrap_column(response.results.columns[0])
|
||||||
logs += new_logs
|
logs += new_logs
|
||||||
if not new_logs:
|
if not new_logs:
|
||||||
break
|
break
|
||||||
return logs
|
return '\n'.join(logs)
|
||||||
|
Loading…
Reference in New Issue
Block a user