Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] fix hive.fetch_logs #2968

Merged
merged 1 commit into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)