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

Method execute_query

benchmarks/src/imdb/run.rs:379–417  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        sql: &str,
    )

Source from the content-addressed store, hash-verified

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,

Callers 1

benchmark_queryMethod · 0.45

Calls 8

sqlMethod · 0.80
into_partsMethod · 0.80
collectFunction · 0.50
optimizeMethod · 0.45
create_physical_planMethod · 0.45
cloneMethod · 0.45
task_ctxMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected