def fetch_fail(self, handle, orientation, expected_error_prefix): """Attempts to fetch rows from the query identified by the given operation handle. Asserts that the fetch returns an error with an error message matching the given expected_error_prefix.""" fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = handle fetch_results_req.orientation = orientation fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) HS2TestSuite.check_response(fetch_results_resp, TCLIService.TStatusCode.ERROR_STATUS, expected_error_prefix) return fetch_results_resp
def fetch(self, handle, orientation, size, expected_num_rows=None): """Fetches at most size number of rows from the query identified by the given operation handle. Uses the given fetch orientation. Asserts that the fetch returns a success status, and that the number of rows returned is equal to size, or equal to the given expected_num_rows (it one was given).""" fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = handle fetch_results_req.orientation = orientation fetch_results_req.maxRows = size fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) HS2TestSuite.check_response(fetch_results_resp) num_rows = size if expected_num_rows is not None: num_rows = expected_num_rows assert len(fetch_results_resp.results.rows) == num_rows return fetch_results_resp
def test_get_schemas(self): get_schemas_req = TCLIService.TGetSchemasReq() get_schemas_req.sessionHandle = self.session_handle get_schemas_resp = self.hs2_client.GetSchemas(get_schemas_req) TestHS2.check_response(get_schemas_resp) fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = get_schemas_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) query_id = operation_id_to_query_id( get_schemas_resp.operationHandle.operationId) profile_page = self.impalad_test_service.read_query_profile_page( query_id) # Test fix for IMPALA-619 assert "Sql Statement: GET_SCHEMAS" in profile_page assert "Query Type: DDL" in profile_page
def get_log(self, query_stmt): execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = query_stmt execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) TestHS2.check_response(execute_statement_resp) # Fetch results to make sure errors are generated fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) get_log_req = TCLIService.TGetLogReq() get_log_req.operationHandle = execute_statement_resp.operationHandle get_log_resp = self.hs2_client.GetLog(get_log_req) TestHS2.check_response(get_log_resp) return get_log_resp.log
def test_execute_select(self): """Test that a simple select statement works""" execute_statement_req = TCLIService.TExecuteStatementReq() execute_statement_req.sessionHandle = self.session_handle execute_statement_req.statement = "SELECT COUNT(*) FROM functional.alltypes" execute_statement_resp = self.hs2_client.ExecuteStatement( execute_statement_req) TestHS2.check_response(execute_statement_resp) fetch_results_req = TCLIService.TFetchResultsReq() fetch_results_req.operationHandle = execute_statement_resp.operationHandle fetch_results_req.maxRows = 100 fetch_results_resp = self.hs2_client.FetchResults(fetch_results_req) TestHS2.check_response(fetch_results_resp) assert len(fetch_results_resp.results.rows) == 1 assert fetch_results_resp.results.startRowOffset == 0 try: assert not fetch_results_resp.hasMoreRows except AssertionError: pytest.xfail("IMPALA-558")