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

Method run_query_stmts_test

tests/hs2/test_fetch_first.py:182–325  ·  view source on GitHub ↗

Tests Impala's limited support for the FETCH_FIRST fetch orientation for queries. Impala permits FETCH_FIRST for a particular query iff result caching is enabled via the 'impala.resultset.cache.size' confOverlay option. FETCH_FIRST will succeed as long as all previously fetched rows fit

(self, conf_overlay=dict())

Source from the content-addressed store, hash-verified

180 return get_profile_resp.profile
181
182 def run_query_stmts_test(self, conf_overlay=dict()):
183 """Tests Impala's limited support for the FETCH_FIRST fetch orientation for queries.
184 Impala permits FETCH_FIRST for a particular query iff result caching is enabled
185 via the 'impala.resultset.cache.size' confOverlay option. FETCH_FIRST will succeed as
186 long as all previously fetched rows fit into the bounded result cache.
187 Regardless of whether a FETCH_FIRST succeeds or not, clients may always resume
188 fetching with FETCH_NEXT.
189 """
190 # Negative tests for the result caching option.
191 self.__test_invalid_result_caching("SELECT COUNT(*) FROM functional.alltypes")
192 # Test that FETCH_NEXT without result caching succeeds and FETCH_FIRST fails.
193 execute_statement_req = TCLIService.TExecuteStatementReq()
194 execute_statement_req.sessionHandle = self.session_handle
195 execute_statement_req.confOverlay = dict()
196 execute_statement_req.confOverlay.update(conf_overlay)
197 execute_statement_req.statement =\
198 "SELECT * FROM functional.alltypessmall ORDER BY id LIMIT 30"
199 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
200 HS2TestSuite.check_response(execute_statement_resp)
201 for i in range(1, 5):
202 # Fetch 10 rows with the FETCH_NEXT orientation.
203 expected_num_rows = 10
204 if i == 4:
205 expected_num_rows = 0
206 self.fetch_until(execute_statement_resp.operationHandle,
207 TCLIService.TFetchOrientation.FETCH_NEXT, 10, expected_num_rows)
208 # Fetch 10 rows with the FETCH_FIRST orientation, expecting an error.
209 # After a failed FETCH_FIRST, the client can still resume FETCH_NEXT.
210 self.fetch_fail(execute_statement_resp.operationHandle,
211 TCLIService.TFetchOrientation.FETCH_FIRST,
212 "Restarting of fetch requires enabling of query result caching")
213 self.__verify_num_cached_rows(0)
214 self.close(execute_statement_resp.operationHandle)
215
216 # Basic test of FETCH_FIRST where the entire result set is cached, and we repeatedly
217 # fetch all results.
218 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "30"
219 execute_statement_req.statement =\
220 "SELECT * FROM functional.alltypessmall ORDER BY id LIMIT 30"
221 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
222 for _ in range(1, 5):
223 self.fetch_until(execute_statement_resp.operationHandle,
224 TCLIService.TFetchOrientation.FETCH_FIRST, 30)
225 self.__verify_num_cached_rows(30)
226 self.close(execute_statement_resp.operationHandle)
227
228 # Test FETCH_NEXT and FETCH_FIRST where the entire result set does not fit into
229 # the cache. FETCH_FIRST will succeed as long as the fetched results
230 # fit into the cache.
231 execute_statement_req.confOverlay[self.IMPALA_RESULT_CACHING_OPT] = "29"
232 execute_statement_req.statement =\
233 "SELECT * FROM functional.alltypessmall ORDER BY id LIMIT 30"
234 execute_statement_resp = self.hs2_client.ExecuteStatement(execute_statement_req)
235 # Fetch 10 rows. They fit in the result cache.
236 self.fetch_until(execute_statement_resp.operationHandle,
237 TCLIService.TFetchOrientation.FETCH_NEXT, 10)
238 self.__verify_num_cached_rows(10)
239 # Restart the fetch and expect success.

Calls 10

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

Tested by

no test coverage detected