(
&self,
ctx: &SessionContext,
sql: &str,
)
| 377 | } |
| 378 | |
| 379 | async fn execute_query( |
| 380 | &self, |
| 381 | ctx: &SessionContext, |
| 382 | sql: &str, |
| 383 | ) -> Result<Vec<RecordBatch>> { |
| 384 | let debug = self.common.debug; |
| 385 | let plan = ctx.sql(sql).await?; |
| 386 | let (state, plan) = plan.into_parts(); |
| 387 | |
| 388 | if debug { |
| 389 | println!("=== Logical plan ===\n{plan}\n"); |
| 390 | } |
| 391 | |
| 392 | let plan = state.optimize(&plan)?; |
| 393 | if debug { |
| 394 | println!("=== Optimized logical plan ===\n{plan}\n"); |
| 395 | } |
| 396 | let physical_plan = state.create_physical_plan(&plan).await?; |
| 397 | if debug { |
| 398 | println!( |
| 399 | "=== Physical plan ===\n{}\n", |
| 400 | displayable(physical_plan.as_ref()).indent(true) |
| 401 | ); |
| 402 | } |
| 403 | let result = collect(physical_plan.clone(), state.task_ctx()).await?; |
| 404 | if debug { |
| 405 | println!( |
| 406 | "=== Physical plan with metrics ===\n{}\n", |
| 407 | DisplayableExecutionPlan::with_metrics(physical_plan.as_ref()) |
| 408 | .indent(true) |
| 409 | ); |
| 410 | if !result.is_empty() { |
| 411 | // do not call print_batches if there are no batches as the result is confusing |
| 412 | // and makes it look like there is a batch with no columns |
| 413 | pretty::print_batches(&result)?; |
| 414 | } |
| 415 | } |
| 416 | Ok(result) |
| 417 | } |
| 418 | |
| 419 | async fn get_table( |
| 420 | &self, |
no test coverage detected