(store: Arc<dyn ObjectStore>)
| 160 | } |
| 161 | |
| 162 | async 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 | |
| 207 | async fn find_or_generate_files( |
| 208 | data_dir: impl AsRef<Path>, |
nothing calls this directly
no test coverage detected
searching dependent graphs…