Test that NumRowsFetched is updated even when a fetch request is served by the results cache, and that RowsMaterialized is only updated when rows are first created (e.g. not when they are served from the cache).
(self)
| 141 | @pytest.mark.execute_serially |
| 142 | @needs_session() |
| 143 | def test_rows_materialized_counters(self): |
| 144 | """Test that NumRowsFetched is updated even when a fetch request is served by the |
| 145 | results cache, and that RowsMaterialized is only updated when rows are first created |
| 146 | (e.g. not when they are served from the cache).""" |
| 147 | num_rows = 10 |
| 148 | statement = "SELECT * FROM functional.alltypes LIMIT {0}".format(num_rows) |
| 149 | num_rows_fetched = "NumRowsFetched: {0} ({0})" |
| 150 | num_rows_fetched_from_cache = "NumRowsFetchedFromCache: {0} ({0})" |
| 151 | |
| 152 | # Execute the query with the results cache enabled. |
| 153 | options = {self.IMPALA_RESULT_CACHING_OPT: str(num_rows)} |
| 154 | handle = self.run_query_expect_success(statement, options) |
| 155 | |
| 156 | # Fetch all rows from the query and verify they have been cached. |
| 157 | self.fetch_until(handle, TCLIService.TFetchOrientation.FETCH_NEXT, num_rows) |
| 158 | self.__verify_num_cached_rows(num_rows) |
| 159 | |
| 160 | # Get the runtime profile and validate that NumRowsFetched and RowsMaterialized both |
| 161 | # equal the number of rows fetched by the query. |
| 162 | profile = self.__get_runtime_profile(handle) |
| 163 | assert num_rows_fetched.format(num_rows) in profile |
| 164 | |
| 165 | # Fetch all rows again and confirm that RowsMaterialized is unchanged, but |
| 166 | # NumRowsFetched is double the number of rows returned by the query. |
| 167 | self.fetch_until(handle, TCLIService.TFetchOrientation.FETCH_FIRST, num_rows) |
| 168 | profile = self.__get_runtime_profile(handle) |
| 169 | assert num_rows_fetched.format(num_rows) in profile |
| 170 | assert num_rows_fetched_from_cache.format(num_rows) in profile |
| 171 | self.close(handle) |
| 172 | |
| 173 | def __get_runtime_profile(self, op_handle): |
| 174 | """Helper method to get the runtime profile from a given operation handle.""" |
nothing calls this directly
no test coverage detected