This is an automated email from the ASF dual-hosted git repository.

johnbodley pushed a commit to branch john-bodley-remove-obsolete-db_engines
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e9ed8eef6b402d711f941c088dd41e4c0cef964f
Author: John Bodley <[email protected]>
AuthorDate: Wed Jul 6 14:37:23 2022 -0700

    Delete __init__.py
    
    Delete hive.py
    
    Update hive.py
---
 superset/db_engine_specs/hive.py | 51 ++--------------------------------------
 1 file changed, 2 insertions(+), 49 deletions(-)

diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py
index 335b570faf..4a881e15b2 100644
--- a/superset/db_engine_specs/hive.py
+++ b/superset/db_engine_specs/hive.py
@@ -149,7 +149,6 @@ class HiveEngineSpec(PrestoEngineSpec):
         hive.TCLIService = patched_TCLIService
         hive.constants = patched_constants
         hive.ttypes = patched_ttypes
-        hive.Cursor.fetch_logs = fetch_logs
 
     @classmethod
     def fetch_data(cls, cursor: Any, limit: int | None = None) -> 
list[tuple[Any, ...]]:
@@ -361,7 +360,8 @@ class HiveEngineSpec(PrestoEngineSpec):
                 break
 
             try:
-                log = cursor.fetch_logs() or ""
+                logs = cursor.fetch_logs()
+                log = "\n".join(logs) if logs else ""
             except Exception:  # pylint: disable=broad-except
                 logger.warning("Call to GetLog() failed")
                 log = ""
@@ -632,50 +632,3 @@ class HiveEngineSpec(PrestoEngineSpec):
             cursor.execute(sql)
             results = cursor.fetchall()
             return {row[0] for row in results}
-
-
-# TODO: contribute back to pyhive.
-def fetch_logs(  # pylint: disable=protected-access
-    self: Cursor,
-    _max_rows: int = 1024,
-    orientation: TFetchOrientation | None = None,
-) -> str:
-    """Mocked. Retrieve the logs produced by the execution of the query.
-    Can be called multiple times to fetch the logs produced after
-    the previous call.
-    :returns: list<str>
-    :raises: ``ProgrammingError`` when no query has been started
-    .. note::
-        This is not a part of DB-API.
-    """
-    # pylint: disable=import-outside-toplevel
-    from pyhive import hive
-    from TCLIService import ttypes
-    from thrift import Thrift
-
-    orientation = orientation or ttypes.TFetchOrientation.FETCH_NEXT
-    try:
-        req = ttypes.TGetLogReq(operationHandle=self._operationHandle)
-        logs = self._connection.client.GetLog(req).log
-        return logs
-    # raised if Hive is used
-    except (ttypes.TApplicationException, Thrift.TApplicationException) as ex:
-        if self._state == self._STATE_NONE:
-            raise hive.ProgrammingError("No query yet") from ex
-        logs = []
-        while True:
-            req = ttypes.TFetchResultsReq(
-                operationHandle=self._operationHandle,
-                orientation=ttypes.TFetchOrientation.FETCH_NEXT,
-                maxRows=self.arraysize,
-                fetchType=1,  # 0: results, 1: logs
-            )
-            response = self._connection.client.FetchResults(req)
-            hive._check_status(response)
-            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 "\n".join(logs)

Reply via email to