(&self, ctx: &SessionContext, sql: &str)
| 204 | } |
| 205 | |
| 206 | async fn execute_query(&self, ctx: &SessionContext, sql: &str) -> Result<usize> { |
| 207 | let debug = self.common.debug; |
| 208 | let plan = ctx.sql(sql).await?; |
| 209 | let (state, plan) = plan.into_parts(); |
| 210 | |
| 211 | if debug { |
| 212 | println!("=== Logical plan ===\n{plan}\n"); |
| 213 | } |
| 214 | |
| 215 | let plan = state.optimize(&plan)?; |
| 216 | if debug { |
| 217 | println!("=== Optimized logical plan ===\n{plan}\n"); |
| 218 | } |
| 219 | let physical_plan = state.create_physical_plan(&plan).await?; |
| 220 | if debug { |
| 221 | println!( |
| 222 | "=== Physical plan ===\n{}\n", |
| 223 | displayable(physical_plan.as_ref()).indent(true) |
| 224 | ); |
| 225 | } |
| 226 | |
| 227 | let mut row_count = 0; |
| 228 | let mut stream = execute_stream(physical_plan.clone(), state.task_ctx())?; |
| 229 | while let Some(batch) = stream.next().await { |
| 230 | row_count += batch?.num_rows(); |
| 231 | } |
| 232 | |
| 233 | if debug { |
| 234 | println!( |
| 235 | "=== Physical plan with metrics ===\n{}\n", |
| 236 | DisplayableExecutionPlan::with_metrics(physical_plan.as_ref()) |
| 237 | .indent(true) |
| 238 | ); |
| 239 | } |
| 240 | |
| 241 | Ok(row_count) |
| 242 | } |
| 243 | |
| 244 | async fn get_table( |
| 245 | &self, |
no test coverage detected