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

Method execute_query

benchmarks/src/tpch/run.rs:239–277  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        sql: &str,
    )

Source from the content-addressed store, hash-verified

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,

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