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

Method fetch_num_rows

tests/hs2/test_fetch_timeout.py:310–331  ·  view source on GitHub ↗

Fetch the specified number of rows in the given op_handle and validate that the number of rows returned matches the expected number of rows. If the op_handle does not return the expected number of rows within a timeout, an error is thrown.

(hs2_client, op_handle, num_rows, statement)

Source from the content-addressed store, hash-verified

308
309 @staticmethod
310 def fetch_num_rows(hs2_client, op_handle, num_rows, statement):
311 """Fetch the specified number of rows in the given op_handle and validate that the
312 number of rows returned matches the expected number of rows. If the op_handle does
313 not return the expected number of rows within a timeout, an error is thrown."""
314 # The timeout to wait for fetch requests to fetch all rows.
315 timeout = 30
316
317 start_time = time()
318 num_fetched = 0
319
320 # Fetch results until either the timeout is hit or all rows have been fetched.
321 while num_fetched != num_rows and time() - start_time < timeout:
322 sleep(0.5)
323 fetch_results_resp = hs2_client.FetchResults(
324 TCLIService.TFetchResultsReq(operationHandle=op_handle,
325 maxRows=num_rows - num_fetched))
326 HS2TestSuite.check_response(fetch_results_resp)
327 num_fetched += HS2TestSuite.get_num_rows(fetch_results_resp.results)
328 if num_fetched != num_rows:
329 raise Timeout("Query {0} did not fetch all results within the timeout {1}"
330 .format(statement, timeout))
331 assert num_fetched == num_rows

Calls 6

TimeoutClass · 0.90
timeFunction · 0.85
check_responseMethod · 0.80
get_num_rowsMethod · 0.80
FetchResultsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected