Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns:
List: Results of the query.
"""
cursor = self.get_cursor()
try:
if isinstance(query_cmds, list):
for query in query_cmds:
cursor.execute(query)
else:
cursor.execute(query_cmds)
try:
results = cursor.fetchall()
except exc.ProgrammingError:
results = []
finally:
return results
except exc.OperationalError as error:
logger.error("Hive Query {} execution failed".format(str(query_cmds)))
raise custom_exceptions.HiveExecutionError from error
def fetch_data(cls, cursor, limit):
import pyhive
from TCLIService import ttypes
state = cursor.poll()
if state.operationState == ttypes.TOperationState.ERROR_STATE:
raise Exception('Query error', state.errorMessage)
try:
return super(HiveEngineSpec, cls).fetch_data(cursor, limit)
except pyhive.exc.ProgrammingError:
return []
def fetch_data(cls, cursor, limit: int) -> List[Tuple]:
import pyhive
from TCLIService import ttypes
state = cursor.poll()
if state.operationState == ttypes.TOperationState.ERROR_STATE:
raise Exception("Query error", state.errorMessage)
try:
return super(HiveEngineSpec, cls).fetch_data(cursor, limit)
except pyhive.exc.ProgrammingError:
return []
cursor = self.get_cursor()
try:
if isinstance(query_cmds, list):
for query in query_cmds:
cursor.execute(query)
else:
cursor.execute(query_cmds)
try:
results = cursor.fetchall()
except exc.ProgrammingError:
results = []
finally:
return results
except exc.OperationalError as error:
logger.error("Hive Query {} execution failed".format(str(query_cmds)))
raise custom_exceptions.HiveExecutionError from error
def escape_args(self, parameters):
if isinstance(parameters, dict):
return {k: self.escape_item(v) for k, v in parameters.items()}
elif isinstance(parameters, (list, tuple)):
return tuple(self.escape_item(x) for x in parameters)
else:
raise exc.ProgrammingError("Unsupported param format: {}".format(parameters))