Skip to content

Commit a280b9c

Browse files
Fix up more doc tests
1 parent 5d319d8 commit a280b9c

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed

datafusion-examples/examples/default_column_values.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,11 @@ impl TableProvider for DefaultValueTableProvider {
262262
.with_expr_adapter(Some(Arc::new(DefaultValuePhysicalExprAdapterFactory) as _))
263263
.build();
264264

265-
let parquet_source =
265+
Ok(DataSourceExec::from_data_source(
266266
ParquetSource::new(TableParquetOptions::default(), config.clone())
267267
.with_predicate(filter)
268-
.with_pushdown_filters(true);
269-
270-
Ok(DataSourceExec::from_data_source(parquet_source))
268+
.with_pushdown_filters(true),
269+
))
271270
}
272271
}
273272

datafusion-examples/examples/json_shredding.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,11 @@ impl TableProvider for ExampleTableProvider {
270270
.with_expr_adapter(Some(Arc::new(ShreddedJsonRewriterFactory) as _))
271271
.build();
272272

273-
let parquet_source =
273+
Ok(DataSourceExec::from_data_source(
274274
ParquetSource::new(TableParquetOptions::default(), config.clone())
275275
.with_predicate(filter)
276-
.with_pushdown_filters(true);
277-
278-
Ok(DataSourceExec::from_data_source(parquet_source))
276+
.with_pushdown_filters(true),
277+
))
279278
}
280279
}
281280

datafusion-examples/examples/parquet_embedded_index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ impl TableProvider for DistinctIndexTable {
440440
builder = builder.with_file(partitioned_file);
441441
}
442442

443-
let config = builder.build();
444-
let source = ParquetSource::new(TableParquetOptions::default(), config.clone())
445-
.with_enable_page_index(true);
446-
Ok(DataSourceExec::from_data_source(source))
443+
Ok(DataSourceExec::from_data_source(
444+
ParquetSource::new(TableParquetOptions::default(), builder.build())
445+
.with_enable_page_index(true),
446+
))
447447
}
448448

449449
/// Tell DataFusion that we can handle filters on the "category" column

datafusion-examples/examples/parquet_index.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,13 @@ impl TableProvider for IndexTableProvider {
260260
);
261261
}
262262

263-
let config = file_scan_config_builder.build();
264-
let source = ParquetSource::new(TableParquetOptions::default(), config.clone())
265-
.with_predicate(predicate);
266-
267-
Ok(DataSourceExec::from_data_source(source))
263+
Ok(DataSourceExec::from_data_source(
264+
ParquetSource::new(
265+
TableParquetOptions::default(),
266+
file_scan_config_builder.build(),
267+
)
268+
.with_predicate(predicate),
269+
))
268270
}
269271

270272
/// Tell DataFusion to push filters down to the scan method

datafusion/core/src/datasource/file_format/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ pub(crate) mod test_util {
8989
.build();
9090

9191
let source = format.file_source(config);
92-
let exec = format.create_physical_plan(state, source).await?;
93-
94-
Ok(exec)
92+
Ok(format.create_physical_plan(state, source).await?)
9593
}
9694
}
9795

datafusion/core/src/datasource/listing/table.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,6 @@ impl ListingTable {
11251125
if let Some(factory) = &self.schema_adapter_factory {
11261126
source = source.with_schema_adapter_factory(Arc::clone(factory))?;
11271127
}
1128-
11291128
Ok(source)
11301129
}
11311130

@@ -1249,12 +1248,13 @@ impl TableProvider for ListingTable {
12491248
.with_expr_adapter(self.expr_adapter_factory.clone())
12501249
.build();
12511250

1252-
let file_source = self.create_file_source_with_schema_adapter(conf)?;
1253-
12541251
// create the execution plan
12551252
self.options
12561253
.format
1257-
.create_physical_plan(state, file_source)
1254+
.create_physical_plan(
1255+
state,
1256+
self.create_file_source_with_schema_adapter(conf)?,
1257+
)
12581258
.await
12591259
}
12601260

datafusion/datasource/src/file_scan_config.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ use log::{debug, warn};
6262
/// # Example
6363
/// ```
6464
/// # use std::any::Any;
65+
/// # use std::fmt::{Debug, Formatter};
6566
/// # use std::sync::Arc;
6667
/// # use arrow::datatypes::{Field, Fields, DataType, Schema, SchemaRef};
6768
/// # use object_store::ObjectStore;
@@ -72,7 +73,7 @@ use log::{debug, warn};
7273
/// # use datafusion_datasource::PartitionedFile;
7374
/// # use datafusion_datasource::file_scan_config::{FileScanConfig, FileScanConfigBuilder};
7475
/// # use datafusion_datasource::file_stream::FileOpener;
75-
/// # use datafusion_datasource::source::DataSourceExec;
76+
/// # use datafusion_datasource::source::{DataSource, DataSourceExec};
7677
/// # use datafusion_execution::object_store::ObjectStoreUrl;
7778
/// # use datafusion_physical_plan::ExecutionPlan;
7879
/// # use datafusion_physical_plan::metrics::ExecutionPlanMetricsSet;
@@ -90,15 +91,19 @@ use log::{debug, warn};
9091
/// # schema_adapter_factory: Option<Arc<dyn SchemaAdapterFactory>>
9192
/// # config: FileScanConfig,
9293
/// # };
93-
/// # impl FileSource for ParquetSource {
94+
/// # impl Debug for ParquetSource {fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { unimplemented!() }}
95+
///
96+
/// impl FileSource for ParquetSource {
9497
/// # fn config(&self) -> &FileScanConfig { &self.config }
98+
/// # fn with_config(&self, config: FileScanConfig) -> Arc<dyn FileSource> { unimplemented!() }
99+
/// # fn as_data_source(&self) -> Arc<dyn DataSource> { Arc::new(self.clone()) }
95100
/// # fn create_file_opener(&self, _: Arc<dyn ObjectStore>, _: usize) -> Arc<dyn FileOpener> { unimplemented!() }
96101
/// # fn as_any(&self) -> &dyn Any { self }
97-
/// # fn metrics(&self) -> &ExecutionPlanMetricsSet { unimplemented!() }
102+
/// # fn metrics_inner(&self) -> &ExecutionPlanMetricsSet { unimplemented!() }
98103
/// # fn file_type(&self) -> &str { "parquet" }
99104
/// # fn with_schema_adapter_factory(&self, factory: Arc<dyn SchemaAdapterFactory>) -> Result<Arc<dyn FileSource>> { Ok(Arc::new(Self {projected_statistics: self.projected_statistics.clone(), schema_adapter_factory: Some(factory), config: self.config.clone() } )) }
100105
/// # fn schema_adapter_factory(&self) -> Option<Arc<dyn SchemaAdapterFactory>> { self.schema_adapter_factory.clone() }
101-
/// # }
106+
/// # }
102107
/// # impl ParquetSource {
103108
/// # fn new(config: FileScanConfig) -> Self { Self {projected_statistics: None, schema_adapter_factory: None, config} }
104109
/// # }
@@ -115,9 +120,8 @@ use log::{debug, warn};
115120
/// PartitionedFile::new("file2.parquet", 56),
116121
/// PartitionedFile::new("file3.parquet", 78),
117122
/// ])).build();
118-
/// let file_source = Arc::new(ParquetSource::new(config.clone()));
119123
/// // create an execution plan from the config
120-
/// let plan: Arc<dyn ExecutionPlan> =DataSourceExec::from_data_source(source);
124+
/// let plan: Arc<dyn ExecutionPlan> =DataSourceExec::from_data_source(ParquetSource::new(config.clone()));
121125
/// ```
122126
#[derive(Clone)]
123127
pub struct FileScanConfig {

0 commit comments

Comments
 (0)