MCPcopy Create free account
hub / github.com/apache/impala / run_query_capture_results

Function run_query_capture_results

tests/performance/query_exec_functions.py:223–251  ·  view source on GitHub ↗

Runs the given query command and returns the execution result. Takes in a match function that is used to parse stderr/stdout to extract the results.

(cmd, query)

Source from the content-addressed store, hash-verified

221
222
223def run_query_capture_results(cmd, query):
224 """
225 Runs the given query command and returns the execution result.
226
227 Takes in a match function that is used to parse stderr/stdout to extract the results.
228 """
229 exec_result = HiveQueryResult(query)
230 start_time = datetime.now()
231 try:
232 rc, stdout, stderr = exec_process(cmd)
233 except Exception as e:
234 LOG.error('Error while executing query command: %s' % e)
235 exec_result.query_error = str(e)
236 # TODO: Should probably save the start time and query string for failed queries.
237 return exec_result
238 if rc != 0:
239 msg = ('Command returned with an error:\n'
240 'rc: %d\n'
241 'STDERR:\n%s'
242 'STDOUT:\n%s'
243 % (rc, stderr, stdout))
244 LOG.error(msg)
245 exec_result.query_error = msg
246 return exec_result
247 # The command completed
248 exec_result = parse_jdbc_query_results(stdout, query)
249 exec_result.query = query
250 exec_result.start_time = start_time
251 return exec_result

Callers 1

execute_using_jdbcFunction · 0.85

Calls 5

HiveQueryResultClass · 0.90
exec_processFunction · 0.90
parse_jdbc_query_resultsFunction · 0.85
nowMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected