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

Method run_query

tests/comparison/leopard/job.py:236–287  ·  view source on GitHub ↗

Runs a single query.

(self, query_model)

Source from the content-addressed store, hash-verified

234 return try_num
235
236 def run_query(self, query_model):
237 '''Runs a single query. '''
238 if not self.is_impala_running():
239 LOG.info('Impala is not running, starting Impala.')
240 self.start_impala()
241
242 def run_query_internal():
243 self.comparison_result = self.query_result_comparator.compare_query_results(
244 query_model)
245
246 self.comparison_result = None
247 internal_thread = Thread(
248 target=run_query_internal,
249 name='run_query_internal_{0}'.format(self.job_id))
250 internal_thread.daemon = True
251 internal_thread.start()
252 internal_thread.join(timeout=600)
253 if internal_thread.is_alive():
254 LOG.info('run_query_internal is alive, restarting Impala Environment')
255 self.impala_env.stop_docker()
256 self.prepare()
257 return None
258 else:
259 LOG.info('run_query_internal is dead as expected')
260
261 comparison_result = self.comparison_result
262
263 if comparison_result.query_timed_out:
264 LOG.info('Query Timeout Exception')
265 restart_impala = True
266 else:
267 restart_impala = False
268
269 result_dict = {}
270
271 if self.is_impala_running():
272 if comparison_result.error:
273 result_dict = self.comparison_result_analysis(comparison_result)
274 result_dict['model'] = query_model
275 elif comparison_result.query_resulted_in_data:
276 self.num_queries_returned_correct_data += 1
277 else:
278 LOG.info('CRASH OCCURED')
279 result_dict = self.comparison_result_analysis(comparison_result)
280 result_dict['model'] = query_model
281 result_dict['stack'] = self.get_stack()
282 result_dict['num_tries_to_reproduce'] = self.reproduce_crash(query_model)
283
284 if restart_impala:
285 self.start_impala()
286
287 return result_dict
288
289 def comparison_result_analysis(self, comparison_result):
290 '''Get useful information from the comparison_result. '''

Callers 1

startMethod · 0.95

Calls 11

is_impala_runningMethod · 0.95
start_impalaMethod · 0.95
prepareMethod · 0.95
get_stackMethod · 0.95
reproduce_crashMethod · 0.95
stop_dockerMethod · 0.80
startMethod · 0.65
ThreadClass · 0.50
formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected