Skip to content

Commit ec6fbb1

Browse files
committed
cleaner api
1 parent 2daf742 commit ec6fbb1

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

datafusion-examples/examples/csv_opener.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
use std::{sync::Arc, vec};
1919

20-
use datafusion::common::Statistics;
2120
use datafusion::{
2221
assert_batches_eq,
2322
datasource::{
@@ -58,11 +57,11 @@ async fn main() -> Result<()> {
5857

5958
let path = std::path::Path::new(&path).canonicalize()?;
6059

61-
let mut scan_config =
60+
let scan_config =
6261
FileScanConfig::new(ObjectStoreUrl::local_filesystem(), schema.clone())
63-
.with_projection(vec![12, 0])
64-
.with_limit(Some(5));
65-
scan_config.add_file(PartitionedFile::new(path.display().to_string(), 10));
62+
.with_projection(Some(vec![12, 0]))
63+
.with_limit(Some(5))
64+
.with_file(PartitionedFile::new(path.display().to_string(), 10));
6665

6766
let result =
6867
FileStream::new(&scan_config, 0, opener, &ExecutionPlanMetricsSet::new())

datafusion-examples/examples/json_opener.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use datafusion::{
2929
error::Result,
3030
physical_plan::metrics::ExecutionPlanMetricsSet,
3131
};
32-
use datafusion_common::Statistics;
3332

3433
use futures::StreamExt;
3534
use object_store::ObjectStore;
@@ -61,12 +60,11 @@ async fn main() -> Result<()> {
6160
Arc::new(object_store),
6261
);
6362

64-
let mut scan_config =
63+
let scan_config =
6564
FileScanConfig::new(ObjectStoreUrl::local_filesystem(), schema.clone())
6665
.with_projection(Some(vec![1, 0]))
67-
.with_limit(5);
68-
69-
scan_config.add_file(PartitionedFile::new(path.to_string(), 10));
66+
.with_limit(Some(5))
67+
.with_file(PartitionedFile::new(path.to_string(), 10));
7068

7169
let result =
7270
FileStream::new(&scan_config, 0, opener, &ExecutionPlanMetricsSet::new())

datafusion/core/src/datasource/physical_plan/file_scan_config.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ impl FileScanConfig {
187187
self
188188
}
189189

190+
/// Add a file as a single group
191+
///
192+
/// See [Self::file_groups] for more information.
193+
pub fn with_file(mut self, file: PartitionedFile) -> Self {
194+
self.add_file(file);
195+
self
196+
}
197+
198+
/// Add a new file group
199+
///
200+
/// See [Self::file_groups] for more information
201+
pub fn with_file_group(mut self, file_group: Vec<PartitionedFile>) -> Self {
202+
self.add_file_group(file_group);
203+
self
204+
}
205+
190206
/// Set the partitioning columns of the files
191207
pub fn with_table_partition_cols(mut self, table_partition_cols: Vec<Field>) -> Self {
192208
self.table_partition_cols = table_partition_cols;

0 commit comments

Comments
 (0)