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

Method fetch_until

tests/hs2/hs2_test_suite.py:235–259  ·  view source on GitHub ↗

Tries to fetch exactly 'size' rows from the given query handle, with the given fetch orientation, by repeatedly issuing fetch(size - num rows already fetched) calls. Returns fewer than 'size' rows if either a fetch() returns 0 rows (indicating EOS) or 'expected_num_rows' rows are returne

(self, handle, orientation, size, expected_num_rows = None)

Source from the content-addressed store, hash-verified

233 return fetch_results_resp
234
235 def fetch_until(self, handle, orientation, size, expected_num_rows = None):
236 """Tries to fetch exactly 'size' rows from the given query handle, with the given
237 fetch orientation, by repeatedly issuing fetch(size - num rows already fetched)
238 calls. Returns fewer than 'size' rows if either a fetch() returns 0 rows (indicating
239 EOS) or 'expected_num_rows' rows are returned. If 'expected_num_rows' is set to None,
240 it defaults to 'size', so that the effect is to both ask for and expect the same
241 number of rows."""
242 assert expected_num_rows is None or (size >= expected_num_rows)
243 fetch_results_req = TCLIService.TFetchResultsReq()
244 fetch_results_req.operationHandle = handle
245 fetch_results_req.orientation = orientation
246 fetch_results_req.maxRows = size
247 fetch_results_resp = self.fetch(fetch_results_req)
248 num_rows_fetched = self.get_num_rows(fetch_results_resp.results)
249 if expected_num_rows is None: expected_num_rows = size
250 while num_rows_fetched < expected_num_rows:
251 # Always try to fetch at most 'size'
252 fetch_results_req.maxRows = size - num_rows_fetched
253 fetch_results_req.orientation = TCLIService.TFetchOrientation.FETCH_NEXT
254 fetch_results_resp = self.fetch(fetch_results_req)
255 last_fetch_size = self.get_num_rows(fetch_results_resp.results)
256 assert last_fetch_size > 0
257 num_rows_fetched += last_fetch_size
258
259 assert num_rows_fetched == expected_num_rows
260
261 def fetch_fail(self, handle, orientation, expected_error_prefix):
262 """Attempts to fetch rows from the query identified by the given operation handle.

Calls 2

fetchMethod · 0.95
get_num_rowsMethod · 0.95

Tested by

no test coverage detected