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

Function datafusion

benchmarks/src/cancellation.rs:162–205  ·  view source on GitHub ↗
(store: Arc<dyn ObjectStore>)

Source from the content-addressed store, hash-verified

160}
161
162async fn datafusion(store: Arc<dyn ObjectStore>) -> Result<()> {
163 let query = "SELECT distinct \"A\", \"B\", \"C\", \"D\", \"E\" FROM \"test_table\"";
164
165 let config = SessionConfig::new()
166 .with_target_partitions(4)
167 .set_bool("datafusion.execution.parquet.pushdown_filters", true);
168 let ctx = SessionContext::new_with_config(config);
169 let object_store_url = ObjectStoreUrl::parse("test:///").unwrap();
170 ctx.register_object_store(object_store_url.as_ref(), Arc::clone(&store));
171
172 let file_format = ParquetFormat::default().with_enable_pruning(true);
173 let listing_options = ListingOptions::new(Arc::new(file_format))
174 .with_file_extension(ParquetFormat::default().get_ext());
175
176 let table_path = ListingTableUrl::parse("test:///data/")?;
177
178 ctx.register_listing_table(
179 "test_table",
180 &table_path,
181 listing_options.clone(),
182 None,
183 None,
184 )
185 .await?;
186
187 println!("Creating logical plan...");
188 let logical_plan = ctx.state().create_logical_plan(query).await?;
189
190 println!("Creating physical plan...");
191 let physical_plan = Arc::new(CoalescePartitionsExec::new(
192 ctx.state().create_physical_plan(&logical_plan).await?,
193 ));
194
195 println!("Executing physical plan...");
196 let partition = 0;
197 let task_context = Arc::new(TaskContext::from(&ctx));
198 let stream = physical_plan.execute(partition, task_context).unwrap();
199
200 println!("Getting results...");
201 let results: Vec<_> = stream.try_collect().await?;
202 println!("Got {} record batches", results.len());
203
204 Ok(())
205}
206
207async fn find_or_generate_files(
208 data_dir: impl AsRef<Path>,

Callers

nothing calls this directly

Calls 14

newFunction · 0.85
set_boolMethod · 0.80
with_enable_pruningMethod · 0.80
with_file_extensionMethod · 0.80
create_logical_planMethod · 0.80
register_object_storeMethod · 0.45
as_refMethod · 0.45
get_extMethod · 0.45
cloneMethod · 0.45
stateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…