(
&self,
ctx: &SessionContext,
sql: &str,
)
| 263 | } |
| 264 | |
| 265 | async fn execute_query( |
| 266 | &self, |
| 267 | ctx: &SessionContext, |
| 268 | sql: &str, |
| 269 | ) -> Result<Vec<RecordBatch>> { |
| 270 | let debug = self.common.debug; |
| 271 | let plan = ctx.sql(sql).await?; |
| 272 | let (state, plan) = plan.into_parts(); |
| 273 | |
| 274 | if debug { |
| 275 | println!("=== Logical plan ===\n{plan}\n"); |
| 276 | } |
| 277 | |
| 278 | let plan = state.optimize(&plan)?; |
| 279 | if debug { |
| 280 | println!("=== Optimized logical plan ===\n{plan}\n"); |
| 281 | } |
| 282 | let physical_plan = state.create_physical_plan(&plan).await?; |
| 283 | if debug { |
| 284 | println!( |
| 285 | "=== Physical plan ===\n{}\n", |
| 286 | displayable(physical_plan.as_ref()).indent(true) |
| 287 | ); |
| 288 | } |
| 289 | let result = collect(physical_plan.clone(), state.task_ctx()).await?; |
| 290 | if debug { |
| 291 | println!( |
| 292 | "=== Physical plan with metrics ===\n{}\n", |
| 293 | DisplayableExecutionPlan::with_metrics(physical_plan.as_ref()) |
| 294 | .indent(true) |
| 295 | ); |
| 296 | if !result.is_empty() { |
| 297 | // do not call print_batches if there are no batches as the result is confusing |
| 298 | // and makes it look like there is a batch with no columns |
| 299 | pretty::print_batches(&result)?; |
| 300 | } |
| 301 | } |
| 302 | Ok(result) |
| 303 | } |
| 304 | |
| 305 | async fn get_table( |
| 306 | &self, |
no test coverage detected