Skip to content

Commit

Permalink
fix hive.fetch_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
timfeirg committed Jun 20, 2017
1 parent 9051e1f commit 38a9d27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,9 @@ def handle_cursor(cls, cursor, query, session):
cursor.cancel()
break

resp = cursor.fetch_logs()
if resp and resp.log:
progress = cls.progress(resp.log)
logs = cursor.fetch_logs()
if logs:
progress = cls.progress(logs)
if progress > query.progress:
query.progress = progress
session.commit()
Expand Down
14 changes: 8 additions & 6 deletions superset/db_engines/hive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyhive import hive
from pythrifthiveapi.TCLIService import ttypes
from thrift import Thrift


# TODO: contribute back to pyhive.
Expand All @@ -15,9 +16,11 @@ def fetch_logs(self, max_rows=1024,
"""
try:
req = ttypes.TGetLogReq(operationHandle=self._operationHandle)
logs = self._connection.client.GetLog(req)
logs = self._connection.client.GetLog(req).log
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:
raise hive.ProgrammingError("No query yet")
logs = []
Expand All @@ -30,12 +33,11 @@ def fetch_logs(self, max_rows=1024,
)
response = self._connection.client.FetchResults(req)
hive._check_status(response)
assert not (
response.results.rows, 'expected data in columnar format'
)
assert not response.results.rows, \
'expected data in columnar format'
assert len(response.results.columns) == 1, response.results.columns
new_logs = hive._unwrap_column(response.results.columns[0])
logs += new_logs
if not new_logs:
break
return logs
return '\n'.join(logs)

0 comments on commit 38a9d27

Please sign in to comment.