Skip to content

Commit

Permalink
feat(rust): Use AsRef<Path> instead of PathBuf in sink_ methods (#17150)
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista committed Jun 24, 2024
1 parent dfc82cc commit 0b1f5ec
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod pivot;
feature = "csv",
feature = "json"
))]
use std::path::PathBuf;
use std::path::Path;
use std::sync::{Arc, Mutex};

pub use anonymous_scan::*;
Expand Down Expand Up @@ -752,10 +752,14 @@ impl LazyFrame {
/// into memory. This methods will return an error if the query cannot be completely done in a
/// streaming fashion.
#[cfg(feature = "parquet")]
pub fn sink_parquet(self, path: PathBuf, options: ParquetWriteOptions) -> PolarsResult<()> {
pub fn sink_parquet(
self,
path: impl AsRef<Path>,
options: ParquetWriteOptions,
) -> PolarsResult<()> {
self.sink(
SinkType::File {
path: Arc::new(path),
path: Arc::new(path.as_ref().to_path_buf()),
file_type: FileType::Parquet(options),
},
"collect().write_parquet()",
Expand Down Expand Up @@ -787,10 +791,10 @@ impl LazyFrame {
/// into memory. This methods will return an error if the query cannot be completely done in a
/// streaming fashion.
#[cfg(feature = "ipc")]
pub fn sink_ipc(self, path: PathBuf, options: IpcWriterOptions) -> PolarsResult<()> {
pub fn sink_ipc(self, path: impl AsRef<Path>, options: IpcWriterOptions) -> PolarsResult<()> {
self.sink(
SinkType::File {
path: Arc::new(path),
path: Arc::new(path.as_ref().to_path_buf()),
file_type: FileType::Ipc(options),
},
"collect().write_ipc()",
Expand Down Expand Up @@ -832,10 +836,10 @@ impl LazyFrame {
/// into memory. This methods will return an error if the query cannot be completely done in a
/// streaming fashion.
#[cfg(feature = "csv")]
pub fn sink_csv(self, path: PathBuf, options: CsvWriterOptions) -> PolarsResult<()> {
pub fn sink_csv(self, path: impl AsRef<Path>, options: CsvWriterOptions) -> PolarsResult<()> {
self.sink(
SinkType::File {
path: Arc::new(path),
path: Arc::new(path.as_ref().to_path_buf()),
file_type: FileType::Csv(options),
},
"collect().write_csv()",
Expand All @@ -846,10 +850,10 @@ impl LazyFrame {
/// into memory. This methods will return an error if the query cannot be completely done in a
/// streaming fashion.
#[cfg(feature = "json")]
pub fn sink_json(self, path: PathBuf, options: JsonWriterOptions) -> PolarsResult<()> {
pub fn sink_json(self, path: impl AsRef<Path>, options: JsonWriterOptions) -> PolarsResult<()> {
self.sink(
SinkType::File {
path: Arc::new(path),
path: Arc::new(path.as_ref().to_path_buf()),
file_type: FileType::Json(options),
},
"collect().write_ndjson()` or `collect().write_json()",
Expand Down

0 comments on commit 0b1f5ec

Please sign in to comment.