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

Method get_table

benchmarks/src/sort_tpch.rs:320–357  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        table: &str,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

register_tablesMethod · 0.45

Calls 15

newFunction · 0.85
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
stateMethod · 0.45
with_optionsMethod · 0.45
cloneMethod · 0.45
table_optionsMethod · 0.45

Tested by

no test coverage detected