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

Method _execute_stmt

shell/impala_shell/impala_shell.py:1485–1621  ·  view source on GitHub ↗

Executes 'query_str' with options self.set_query_options on the Impala server. The query is run to completion and close with any results, warnings, errors or other output that we want to display to users printed to the output. Results for queries are streamed from the server and displaye

(self, query_str, is_dml=False, print_web_link=False)

Source from the content-addressed store, hash-verified

1483 self._print_if_verbose(row_report)
1484
1485 def _execute_stmt(self, query_str, is_dml=False, print_web_link=False):
1486 """Executes 'query_str' with options self.set_query_options on the Impala server.
1487 The query is run to completion and close with any results, warnings, errors or
1488 other output that we want to display to users printed to the output.
1489 Results for queries are streamed from the server and displayed as they become
1490 available.
1491 is_dml: True iff the caller detects that 'query_str' is a DML statement, false
1492 otherwise.
1493 print_web_link: if True, a link to the query on the Impala debug webserver is printed.
1494 """
1495 self._print_if_verbose("Query: %s" % query_str)
1496 # TODO: Clean up this try block and refactor it (IMPALA-3814)
1497 try:
1498 if not self.webserver_address:
1499 print_web_link = False
1500 if print_web_link:
1501 self._print_if_verbose("Query submitted at: %s (Coordinator: %s)" %
1502 (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
1503 self.webserver_address))
1504
1505 start_time = time.time()
1506 self.last_query_handle = None
1507 self.last_query_handle = self.imp_client.execute_query(
1508 query_str, self.set_query_options)
1509 self.last_summary = time.time()
1510 if print_web_link:
1511 self._print_if_verbose(
1512 "Query state can be monitored at: %s" % self.imp_client.get_query_link(
1513 self.imp_client.get_query_id_str(self.last_query_handle)))
1514
1515 self.imp_client.wait_to_finish(
1516 self.last_query_handle, self._periodic_wait_callback)
1517 # Reset the progress stream.
1518 self.progress_stream.clear()
1519
1520 if is_dml:
1521 # retrieve the error log
1522 warning_log = self.imp_client.get_warning_log(self.last_query_handle)
1523 dml_result = self.imp_client.close_dml(self.last_query_handle)
1524 else:
1525 # impalad does not support the fetching of metadata for certain types of queries.
1526 if not self.imp_client.expect_result_metadata(query_str, self.last_query_handle):
1527 # Close the query
1528 self.imp_client.close_query(self.last_query_handle)
1529 self._format_no_result_set(query_str, start_time)
1530 return CmdStatus.SUCCESS
1531
1532 self._format_outputstream()
1533 # fetch returns a generator
1534 rows_fetched = self.imp_client.fetch(self.last_query_handle)
1535 num_rows = 0
1536
1537 for rows in rows_fetched:
1538 # IMPALA-4418: Break out of the loop to prevent printing an unnecessary
1539 # empty line.
1540 if len(rows) == 0:
1541 continue
1542 self.output_stream.write(rows)

Callers 14

do_alterMethod · 0.95
do_createMethod · 0.95
do_dropMethod · 0.95
do_loadMethod · 0.95
do_selectMethod · 0.95
do_computeMethod · 0.95
do_valuesMethod · 0.95
do_withMethod · 0.95
do_useMethod · 0.95
do_showMethod · 0.95
__do_describeMethod · 0.95
__do_dmlMethod · 0.95

Calls 15

_print_if_verboseMethod · 0.95
_format_no_result_setMethod · 0.95
_format_outputstreamMethod · 0.95
print_runtime_profileMethod · 0.95
close_connectionMethod · 0.95
log_timestampFunction · 0.90
get_query_linkMethod · 0.80
wait_to_finishMethod · 0.80
encodeMethod · 0.80

Tested by

no test coverage detected