(
&self,
ctx: &SessionContext,
table: &str,
)
| 318 | } |
| 319 | |
| 320 | async fn get_table( |
| 321 | &self, |
| 322 | ctx: &SessionContext, |
| 323 | table: &str, |
| 324 | ) -> Result<Arc<dyn TableProvider>> { |
| 325 | let path = self.path.to_str().unwrap(); |
| 326 | |
| 327 | // Obtain a snapshot of the SessionState |
| 328 | let state = ctx.state(); |
| 329 | let path = format!("{path}/{table}"); |
| 330 | let format = Arc::new( |
| 331 | ParquetFormat::default() |
| 332 | .with_options(ctx.state().table_options().parquet.clone()), |
| 333 | ); |
| 334 | let extension = DEFAULT_PARQUET_EXTENSION; |
| 335 | |
| 336 | let options = ListingOptions::new(format) |
| 337 | .with_file_extension(extension) |
| 338 | .with_collect_stat(state.config().collect_statistics()); |
| 339 | |
| 340 | let table_path = ListingTableUrl::parse(path)?; |
| 341 | let schema = options.infer_schema(&state, &table_path).await?; |
| 342 | let options = if self.sorted { |
| 343 | let key_column_name = schema.fields()[0].name(); |
| 344 | options |
| 345 | .with_file_sort_order(vec![vec![col(key_column_name).sort(true, false)]]) |
| 346 | } else { |
| 347 | options |
| 348 | }; |
| 349 | |
| 350 | let config = ListingTableConfig::new(table_path) |
| 351 | .with_listing_options(options) |
| 352 | .with_schema(schema); |
| 353 | |
| 354 | Ok(Arc::new(ListingTable::try_new(config)?.with_cache( |
| 355 | ctx.runtime_env().cache_manager.get_file_statistic_cache(), |
| 356 | ))) |
| 357 | } |
| 358 | |
| 359 | fn iterations(&self) -> usize { |
| 360 | self.common.iterations |
no test coverage detected