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

Method get_table

benchmarks/src/tpcds/run.rs:305–353  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        table: &str,
    )

Source from the content-addressed store, hash-verified

303 }
304
305 async fn get_table(
306 &self,
307 ctx: &SessionContext,
308 table: &str,
309 ) -> Result<Arc<dyn TableProvider>> {
310 let path = self.path.to_str().unwrap();
311 let target_partitions = self.partitions();
312
313 // Obtain a snapshot of the SessionState
314 let state = ctx.state();
315 let path = format!("{path}/{table}.parquet");
316
317 // Check if the file exists
318 if !std::path::Path::new(&path).exists() {
319 eprintln!("Warning registering {table}: Table file does not exist: {path}");
320 }
321
322 let format = ParquetFormat::default()
323 .with_options(ctx.state().table_options().parquet.clone());
324
325 let table_path = ListingTableUrl::parse(path)?;
326 let options = ListingOptions::new(Arc::new(format))
327 .with_file_extension(DEFAULT_PARQUET_EXTENSION)
328 .with_target_partitions(target_partitions)
329 .with_collect_stat(state.config().collect_statistics());
330 let schema = options.infer_schema(&state, &table_path).await?;
331
332 if self.common.debug {
333 println!(
334 "Inferred schema from {table_path} for table '{table}':\n{schema:#?}\n"
335 );
336 }
337
338 let options = if self.sorted {
339 let key_column_name = schema.fields()[0].name();
340 options
341 .with_file_sort_order(vec![vec![col(key_column_name).sort(true, false)]])
342 } else {
343 options
344 };
345
346 let config = ListingTableConfig::new(table_path)
347 .with_listing_options(options)
348 .with_schema(schema);
349
350 Ok(Arc::new(ListingTable::try_new(config)?.with_cache(
351 ctx.runtime_env().cache_manager.get_file_statistic_cache(),
352 )))
353 }
354
355 fn iterations(&self) -> usize {
356 self.common.iterations

Callers 1

register_tablesMethod · 0.45

Calls 15

newFunction · 0.85
existsMethod · 0.80
with_collect_statMethod · 0.80
with_file_extensionMethod · 0.80
collect_statisticsMethod · 0.80
with_file_sort_orderMethod · 0.80
with_listing_optionsMethod · 0.80
with_cacheMethod · 0.80
partitionsMethod · 0.45
stateMethod · 0.45
with_optionsMethod · 0.45

Tested by

no test coverage detected