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

Method test_constant_query_stmts

tests/hs2/test_fetch_first.py:329–369  ·  view source on GitHub ↗

Tests query stmts that return a constant result set. These queries are handled somewhat specially by Impala, therefore, we test them separately. We expect FETCH_FIRST to always succeed if result caching is enabled.

(self)

Source from the content-addressed store, hash-verified

327 @pytest.mark.execute_serially
328 @needs_session()
329 def test_constant_query_stmts(self):
330 """Tests query stmts that return a constant result set. These queries are handled
331 somewhat specially by Impala, therefore, we test them separately. We expect
332 FETCH_FIRST to always succeed if result caching is enabled."""
333 # Tests a query with limit 0.
334 execute_statement_req = TCLIService.TExecuteStatementReq()
335 execute_statement_req.sessionHandle = self.session_handle
336 execute_statement_req.confOverlay = dict()
337 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "10"
338 execute_statement_req.statement =\
339 "SELECT * FROM functional.alltypessmall ORDER BY id LIMIT 0"
340 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
341 for i in range(0, 3):
342 # Fetch some rows. Expect to get 0 rows.
343 self.fetch_at_most(execute_statement_resp.operationHandle,
344 TCLIService.TFetchOrientation.FETCH_NEXT, i * 10, 0)
345 self.__verify_num_cached_rows(0)
346 # Fetch some rows with FETCH_FIRST. Expect to get 0 rows.
347 self.fetch_at_most(execute_statement_resp.operationHandle,
348 TCLIService.TFetchOrientation.FETCH_FIRST, i * 10, 0)
349 self.__verify_num_cached_rows(0)
350 self.close(execute_statement_resp.operationHandle)
351
352 # Tests a constant select.
353 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "10"
354 execute_statement_req.statement = "SELECT 1, 1.0, 'a', trim('abc'), NULL"
355 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
356 # Fetch 100 rows with FETCH_FIRST. Expect to get 1 row.
357 self.fetch_at_most(execute_statement_resp.operationHandle,
358 TCLIService.TFetchOrientation.FETCH_FIRST, 100, 1)
359 self.__verify_num_cached_rows(1)
360 for i in range(0, 3):
361 # Fetch some rows with FETCH_FIRST. Expect to get 1 row.
362 self.fetch_at_most(execute_statement_resp.operationHandle,
363 TCLIService.TFetchOrientation.FETCH_FIRST, i * 10, 1)
364 self.__verify_num_cached_rows(1)
365 # Fetch some more rows. Expect to get 0 rows.
366 self.fetch_at_most(execute_statement_resp.operationHandle,
367 TCLIService.TFetchOrientation.FETCH_NEXT, i * 10, 0)
368 self.__verify_num_cached_rows(1)
369 self.close(execute_statement_resp.operationHandle)
370
371 @pytest.mark.execute_serially
372 @needs_session()

Callers

nothing calls this directly

Calls 5

rangeFunction · 0.85
fetch_at_mostMethod · 0.80
closeMethod · 0.65
ExecuteStatementMethod · 0.45

Tested by

no test coverage detected