(
&self,
ctx: &SessionContext,
sql: &str,
)
| 237 | } |
| 238 | |
| 239 | async fn execute_query( |
| 240 | &self, |
| 241 | ctx: &SessionContext, |
| 242 | sql: &str, |
| 243 | ) -> Result<Vec<RecordBatch>> { |
| 244 | let debug = self.common.debug; |
| 245 | let plan = ctx.sql(sql).await?; |
| 246 | let (state, plan) = plan.into_parts(); |
| 247 | |
| 248 | if debug { |
| 249 | println!("=== Logical plan ===\n{plan}\n"); |
| 250 | } |
| 251 | |
| 252 | let plan = state.optimize(&plan)?; |
| 253 | if debug { |
| 254 | println!("=== Optimized logical plan ===\n{plan}\n"); |
| 255 | } |
| 256 | let physical_plan = state.create_physical_plan(&plan).await?; |
| 257 | if debug { |
| 258 | println!( |
| 259 | "=== Physical plan ===\n{}\n", |
| 260 | displayable(physical_plan.as_ref()).indent(true) |
| 261 | ); |
| 262 | } |
| 263 | let result = collect(physical_plan.clone(), state.task_ctx()).await?; |
| 264 | if debug { |
| 265 | println!( |
| 266 | "=== Physical plan with metrics ===\n{}\n", |
| 267 | DisplayableExecutionPlan::with_metrics(physical_plan.as_ref()) |
| 268 | .indent(true) |
| 269 | ); |
| 270 | if !result.is_empty() { |
| 271 | // do not call print_batches if there are no batches as the result is confusing |
| 272 | // and makes it look like there is a batch with no columns |
| 273 | pretty::print_batches(&result)?; |
| 274 | } |
| 275 | } |
| 276 | Ok(result) |
| 277 | } |
| 278 | |
| 279 | async fn get_table( |
| 280 | &self, |
no test coverage detected