File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
datafusion/core/src/datasource/listing Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ impl ListingOptions {
245245
246246 /// Set file extension on [`ListingOptions`] and returns self.
247247 ///
248+ /// # Example
248249 /// ```
249250 /// # use std::sync::Arc;
250251 /// # use datafusion::prelude::SessionContext;
@@ -262,6 +263,33 @@ impl ListingOptions {
262263 self
263264 }
264265
266+ /// Optionally set file extension on [`ListingOptions`] and returns self.
267+ ///
268+ /// If `file_extension` is `None`, the file extension will not be changed
269+ ///
270+ /// # Example
271+ /// ```
272+ /// # use std::sync::Arc;
273+ /// # use datafusion::prelude::SessionContext;
274+ /// # use datafusion::datasource::{listing::ListingOptions, file_format::parquet::ParquetFormat};
275+ /// let extension = Some(".parquet");
276+ /// let listing_options = ListingOptions::new(Arc::new(
277+ /// ParquetFormat::default()
278+ /// ))
279+ /// .with_file_extension_opt(extension);
280+ ///
281+ /// assert_eq!(listing_options.file_extension, ".parquet");
282+ /// ```
283+ pub fn with_file_extension_opt < S > ( mut self , file_extension : Option < S > ) -> Self
284+ where
285+ S : Into < String > ,
286+ {
287+ if let Some ( file_extension) = file_extension {
288+ self . file_extension = file_extension. into ( ) ;
289+ }
290+ self
291+ }
292+
265293 /// Set `table partition columns` on [`ListingOptions`] and returns self.
266294 ///
267295 /// "partition columns," used to support [Hive Partitioning], are
You can’t perform that action at this time.
0 commit comments