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

Method execute_query

benchmarks/src/sort_pushdown.rs:206–242  ·  view source on GitHub ↗
(&self, ctx: &SessionContext, sql: &str)

Source from the content-addressed store, hash-verified

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,

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