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

Function scan_format

datafusion/core/src/datasource/file_format/mod.rs:50–93  ·  view source on GitHub ↗
(
        state: &dyn Session,
        format: &dyn FileFormat,
        schema: Option<SchemaRef>,
        store_root: &str,
        file_name: &str,
        projection: Option<Vec<usize>>,
        li

Source from the content-addressed store, hash-verified

48 use crate::test::object_store::local_unpartitioned_file;
49
50 pub async fn scan_format(
51 state: &dyn Session,
52 format: &dyn FileFormat,
53 schema: Option<SchemaRef>,
54 store_root: &str,
55 file_name: &str,
56 projection: Option<Vec<usize>>,
57 limit: Option<usize>,
58 ) -> Result<Arc<dyn datafusion_physical_plan::ExecutionPlan>> {
59 let store = Arc::new(object_store::local::LocalFileSystem::new()) as _;
60 let meta = local_unpartitioned_file(format!("{store_root}/{file_name}"));
61
62 let file_schema = if let Some(file_schema) = schema {
63 file_schema
64 } else {
65 format
66 .infer_schema(state, &store, std::slice::from_ref(&meta))
67 .await?
68 };
69
70 let table_schema = TableSchema::new(file_schema.clone(), vec![]);
71
72 let statistics = format
73 .infer_stats(state, &store, file_schema.clone(), &meta)
74 .await?;
75
76 let file_groups = vec![vec![PartitionedFile::new_from_meta(meta)].into()];
77
78 let exec = format
79 .create_physical_plan(
80 state,
81 FileScanConfigBuilder::new(
82 ObjectStoreUrl::local_filesystem(),
83 format.file_source(table_schema),
84 )
85 .with_file_groups(file_groups)
86 .with_statistics(statistics)
87 .with_projection_indices(projection)?
88 .with_limit(limit)
89 .build(),
90 )
91 .await?;
92 Ok(exec)
93 }
94}
95
96#[cfg(test)]

Callers 10

get_execFunction · 0.85
get_execFunction · 0.85
infer_schemaFunction · 0.85
get_execFunction · 0.85
get_execFunction · 0.85

Calls 12

newFunction · 0.85
local_unpartitioned_fileFunction · 0.85
with_file_groupsMethod · 0.80
infer_schemaMethod · 0.45
cloneMethod · 0.45
infer_statsMethod · 0.45
create_physical_planMethod · 0.45
buildMethod · 0.45
with_limitMethod · 0.45
with_statisticsMethod · 0.45
file_sourceMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…