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

Method execute_query

benchmarks/src/bin/external_aggr.rs:265–303  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        sql: &str,
    )

Source from the content-addressed store, hash-verified

263 }
264
265 async fn execute_query(
266 &self,
267 ctx: &SessionContext,
268 sql: &str,
269 ) -> Result<Vec<RecordBatch>> {
270 let debug = self.common.debug;
271 let plan = ctx.sql(sql).await?;
272 let (state, plan) = plan.into_parts();
273
274 if debug {
275 println!("=== Logical plan ===\n{plan}\n");
276 }
277
278 let plan = state.optimize(&plan)?;
279 if debug {
280 println!("=== Optimized logical plan ===\n{plan}\n");
281 }
282 let physical_plan = state.create_physical_plan(&plan).await?;
283 if debug {
284 println!(
285 "=== Physical plan ===\n{}\n",
286 displayable(physical_plan.as_ref()).indent(true)
287 );
288 }
289 let result = collect(physical_plan.clone(), state.task_ctx()).await?;
290 if debug {
291 println!(
292 "=== Physical plan with metrics ===\n{}\n",
293 DisplayableExecutionPlan::with_metrics(physical_plan.as_ref())
294 .indent(true)
295 );
296 if !result.is_empty() {
297 // do not call print_batches if there are no batches as the result is confusing
298 // and makes it look like there is a batch with no columns
299 pretty::print_batches(&result)?;
300 }
301 }
302 Ok(result)
303 }
304
305 async fn get_table(
306 &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