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

Method get_table

benchmarks/src/sort_pushdown.rs:244–279  ·  view source on GitHub ↗
(
        &self,
        ctx: &SessionContext,
        table: &str,
    )

Source from the content-addressed store, hash-verified

242 }
243
244 async fn get_table(
245 &self,
246 ctx: &SessionContext,
247 table: &str,
248 ) -> Result<Arc<dyn TableProvider>> {
249 let path = self.path.to_str().unwrap();
250 let state = ctx.state();
251 let path = format!("{path}/{table}");
252 let format = Arc::new(
253 ParquetFormat::default()
254 .with_options(ctx.state().table_options().parquet.clone()),
255 );
256 let extension = DEFAULT_PARQUET_EXTENSION;
257
258 let options = ListingOptions::new(format)
259 .with_file_extension(extension)
260 .with_collect_stat(true); // Always collect statistics for sort pushdown
261
262 let table_path = ListingTableUrl::parse(path)?;
263 let schema = options.infer_schema(&state, &table_path).await?;
264 let options = if self.sorted {
265 let key_column_name = schema.fields()[0].name();
266 options
267 .with_file_sort_order(vec![vec![col(key_column_name).sort(true, false)]])
268 } else {
269 options
270 };
271
272 let config = ListingTableConfig::new(table_path)
273 .with_listing_options(options)
274 .with_schema(schema);
275
276 Ok(Arc::new(ListingTable::try_new(config)?.with_cache(
277 ctx.runtime_env().cache_manager.get_file_statistic_cache(),
278 )))
279 }
280
281 fn iterations(&self) -> usize {
282 self.common.iterations

Callers 1

register_tablesMethod · 0.45

Calls 15

newFunction · 0.85
with_collect_statMethod · 0.80
with_file_extensionMethod · 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
infer_schemaMethod · 0.45

Tested by

no test coverage detected