waynexia commented on a change in pull request #8910:
URL: https://github.com/apache/arrow/pull/8910#discussion_r543037102
##########
File path: rust/datafusion/src/logical_plan/builder.rs
##########
@@ -90,77 +75,51 @@ impl LogicalPlanBuilder {
options: CsvReadOptions,
projection: Option<Vec<usize>>,
) -> Result<Self> {
- let schema: Schema = match options.schema {
- Some(s) => s.to_owned(),
- None => CsvFile::try_new(path, options)?
- .schema()
- .as_ref()
- .to_owned(),
- };
-
- let projected_schema = projection
- .map(|p| Schema::new(p.iter().map(|i|
schema.field(*i).clone()).collect()))
- .map_or(SchemaRef::new(schema), SchemaRef::new)
- .to_dfschema_ref()?;
-
let provider = Arc::new(CsvFile::try_new(path, options)?);
- let schema = provider.schema();
-
- let table_scan = LogicalPlan::TableScan {
- schema_name: "".to_string(),
- source: TableSource::FromProvider(provider),
- table_schema: schema,
- projected_schema,
- projection: None,
- };
-
- Ok(Self::from(&table_scan))
+ Self::scan("", provider, projection)
}
/// Scan a Parquet data source
pub fn scan_parquet(path: &str, projection: Option<Vec<usize>>) ->
Result<Self> {
let provider = Arc::new(ParquetTable::try_new(path)?);
+ Self::scan("", provider, projection)
+ }
+
+ /// Scan an empty data source, mainly used in tests
+ pub fn scan_empty(
+ name: &str,
Review comment:
Maybe we can remove this parameter and provide `scan()` a placeholder
like `""`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]