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

Method test_non_query_stmts

tests/hs2/test_fetch_first.py:373–443  ·  view source on GitHub ↗

Tests Impala's limited support for the FETCH_FIRST fetch orientation for non-query stmts that return a result set, such as SHOW, COMPUTE STATS, etc. The results of non-query statements are always cached entirely, and therefore, the cache can never be exhausted, i.e., FETCH_FIRST should a

(self)

Source from the content-addressed store, hash-verified

371 @pytest.mark.execute_serially
372 @needs_session()
373 def test_non_query_stmts(self):
374 """Tests Impala's limited support for the FETCH_FIRST fetch orientation for
375 non-query stmts that return a result set, such as SHOW, COMPUTE STATS, etc.
376 The results of non-query statements are always cached entirely, and therefore,
377 the cache can never be exhausted, i.e., FETCH_FIRST should always succeed.
378 However, we only allow FETCH_FIRST on non-query stmts if query caching was enabled
379 by the client for consistency. We use a 'show stats' stmt as a representative
380 of these types of non-query stmts.
381 """
382 # Negative tests for the result caching option.
383 self.__test_invalid_result_caching("show table stats functional.alltypes")
384
385 # Test that FETCH_NEXT without result caching succeeds and FETCH_FIRST fails.
386 # The show stmt returns exactly 25 results.
387 execute_statement_req = TCLIService.TExecuteStatementReq()
388 execute_statement_req.sessionHandle = self.session_handle
389 execute_statement_req.confOverlay = dict()
390 execute_statement_req.statement = "show table stats functional.alltypes"
391 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
392 HS2TestSuite.check_response(execute_statement_resp)
393 for i in range(1, 5):
394 # Fetch 10 rows with the FETCH_NEXT orientation.
395 expected_num_rows = 10
396 if i == 3:
397 expected_num_rows = 5
398 if i == 4:
399 expected_num_rows = 0
400 self.fetch_until(execute_statement_resp.operationHandle,
401 TCLIService.TFetchOrientation.FETCH_NEXT, 10, expected_num_rows)
402 # Fetch 10 rows with the FETCH_FIRST orientation, expecting an error.
403 # After a failed FETCH_FIRST, the client can still resume FETCH_NEXT.
404 self.fetch_fail(execute_statement_resp.operationHandle,
405 TCLIService.TFetchOrientation.FETCH_FIRST,
406 "Restarting of fetch requires enabling of query result caching")
407 # The results of non-query stmts are not counted as 'cached'.
408 self.__verify_num_cached_rows(0)
409
410 # Tests that FETCH_FIRST always succeeds as long as result caching is enabled.
411 # The show stmt returns exactly 25 results. The cache cannot be exhausted.
412 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "1"
413 execute_statement_req.statement = "show table stats functional.alltypes"
414 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
415 HS2TestSuite.check_response(execute_statement_resp)
416 for _ in range(1, 5):
417 self.fetch_until(execute_statement_resp.operationHandle,
418 TCLIService.TFetchOrientation.FETCH_FIRST, 30, 25)
419 # The results of non-query stmts are not counted as 'cached'.
420 self.__verify_num_cached_rows(0)
421
422 # Test combinations of FETCH_FIRST and FETCH_NEXT.
423 # The show stmt returns exactly 25 results.
424 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "1"
425 execute_statement_req.statement = "show table stats functional.alltypes"
426 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
427 HS2TestSuite.check_response(execute_statement_resp)
428 # Fetch 10 rows.
429 self.fetch_until(execute_statement_resp.operationHandle,
430 TCLIService.TFetchOrientation.FETCH_NEXT, 10)

Callers

nothing calls this directly

Calls 8

rangeFunction · 0.85
check_responseMethod · 0.80
fetch_untilMethod · 0.80
fetch_failMethod · 0.80
closeMethod · 0.65
ExecuteStatementMethod · 0.45

Tested by

no test coverage detected