Runs the specified query and returns a string representation of the results suitable for comparison with insta snapshots Clears all recorded requests before running the query
(&self, sql: &str)
| 1236 | /// |
| 1237 | /// Clears all recorded requests before running the query |
| 1238 | async fn query(&self, sql: &str) -> String { |
| 1239 | self.object_store.clear_requests(); |
| 1240 | let results = self |
| 1241 | .session_context |
| 1242 | .sql(sql) |
| 1243 | .await |
| 1244 | .unwrap() |
| 1245 | .collect() |
| 1246 | .await |
| 1247 | .unwrap(); |
| 1248 | |
| 1249 | let num_rows = results.iter().map(|batch| batch.num_rows()).sum::<usize>(); |
| 1250 | let formatted_result = |
| 1251 | arrow::util::pretty::pretty_format_batches(&results).unwrap(); |
| 1252 | |
| 1253 | let object_store = &self.object_store; |
| 1254 | |
| 1255 | format!( |
| 1256 | r#"------- Query Output ({num_rows} rows) ------- |
| 1257 | {formatted_result} |
| 1258 | ------- Object Store Request Summary ------- |
| 1259 | {object_store} |
| 1260 | "# |
| 1261 | ) |
| 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | /// Details of individual requests made through the [`RequestCountingObjectStore`] |
no test coverage detected