MCPcopy Create free account
hub / github.com/apache/datafusion / execute_query

Method execute_query

benchmarks/src/sort_tpch.rs:281–318  ·  view source on GitHub ↗
(&self, ctx: &SessionContext, sql: &str)

Source from the content-addressed store, hash-verified

279 }
280
281 async fn execute_query(&self, ctx: &SessionContext, sql: &str) -> Result<usize> {
282 let debug = self.common.debug;
283 let plan = ctx.sql(sql).await?;
284 let (state, plan) = plan.into_parts();
285
286 if debug {
287 println!("=== Logical plan ===\n{plan}\n");
288 }
289
290 let plan = state.optimize(&plan)?;
291 if debug {
292 println!("=== Optimized logical plan ===\n{plan}\n");
293 }
294 let physical_plan = state.create_physical_plan(&plan).await?;
295 if debug {
296 println!(
297 "=== Physical plan ===\n{}\n",
298 displayable(physical_plan.as_ref()).indent(true)
299 );
300 }
301
302 let mut row_count = 0;
303
304 let mut stream = execute_stream(physical_plan.clone(), state.task_ctx())?;
305 while let Some(batch) = stream.next().await {
306 row_count += batch?.num_rows();
307 }
308
309 if debug {
310 println!(
311 "=== Physical plan with metrics ===\n{}\n",
312 DisplayableExecutionPlan::with_metrics(physical_plan.as_ref())
313 .indent(true)
314 );
315 }
316
317 Ok(row_count)
318 }
319
320 async fn get_table(
321 &self,

Callers 1

benchmark_queryMethod · 0.45

Calls 8

execute_streamFunction · 0.85
sqlMethod · 0.80
into_partsMethod · 0.80
optimizeMethod · 0.45
create_physical_planMethod · 0.45
cloneMethod · 0.45
task_ctxMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected