Skip to content

Apache DataFusion SQL Query Engine

ARROW-10454: [Rust] [Datafusion] support creating ParquetExec from filelist and schema

Qingping Hou26b34b0adf7c
diff --git a/rust/datafusion/src/physical_plan/parquet.rs b/rust/datafusion/src/physical_plan/parquet.rs
index 85a2346f30..8b9f3b27a7 100644
--- a/rust/datafusion/src/physical_plan/parquet.rs
+++ b/rust/datafusion/src/physical_plan/parquet.rs
@@ -70,24 +70,34 @@ impl ParquetExec {
let mut arrow_reader = ParquetFileArrowReader::new(file_reader);
let schema = arrow_reader.get_schema()?;
- let projection = match projection {
- Some(p) => p,
- None => (0..schema.fields().len()).collect(),
- };
-
- let projected_schema = Schema::new(
- projection
- .iter()
- .map(|i| schema.field(*i).clone())
- .collect(),
- );
-
- Ok(Self {
- filenames,
- schema: Arc::new(projected_schema),
- projection,
- batch_size,
- })
+ Ok(Self::new(filenames, schema, projection, batch_size))
+ }
+ }
+
+ /// Create a new Parquet reader execution plan with provided files and schema
+ pub fn new(
+ filenames: Vec<String>,
+ schema: Schema,
+ projection: Option<Vec<usize>>,
+ batch_size: usize,
+ ) -> Self {
+ let projection = match projection {
+ Some(p) => p,
+ None => (0..schema.fields().len()).collect(),
+ };
+
+ let projected_schema = Schema::new(
+ projection
+ .iter()
+ .map(|i| schema.field(*i).clone())
+ .collect(),
+ );
+
+ Self {
+ filenames,
+ schema: Arc::new(projected_schema),
+ projection,
+ batch_size,
}
}
}