Skip to content

Commit 0a5db8b

Browse files
committed
refactor: reintroduce From implementation for ParquetSource and add generic From for FileSource
1 parent f69b80e commit 0a5db8b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

datafusion/datasource-parquet/src/source.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,6 @@ pub(crate) fn parse_coerce_int96_string(
432432
}
433433
}
434434

435-
/// Allows easy conversion from ParquetSource to Arc<dyn FileSource>
436-
impl From<ParquetSource> for Arc<dyn FileSource> {
437-
fn from(source: ParquetSource) -> Self {
438-
Arc::new(source)
439-
}
440-
}
441-
442435
impl FileSource for ParquetSource {
443436
fn create_file_opener(
444437
&self,
@@ -670,3 +663,10 @@ impl FileSource for ParquetSource {
670663
self.schema_adapter_factory.clone()
671664
}
672665
}
666+
667+
/// Allows easy conversion from ParquetSource to Arc<dyn FileSource>
668+
impl From<ParquetSource> for Arc<dyn FileSource> {
669+
fn from(source: ParquetSource) -> Self {
670+
Arc::new(source)
671+
}
672+
}

datafusion/datasource/src/file.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ pub trait FileSource: Send + Sync {
131131
/// Returns the current schema adapter factory if set
132132
fn schema_adapter_factory(&self) -> Option<Arc<dyn SchemaAdapterFactory>>;
133133
}
134+
135+
/// Allows easy conversion from any type implementing FileSource to Arc<dyn FileSource>
136+
impl<T: FileSource + 'static> From<T> for Arc<dyn FileSource> {
137+
fn from(source: T) -> Self {
138+
Arc::new(source)
139+
}
140+
}

0 commit comments

Comments
 (0)