From 04cc6a0b606c1576484d9dcb7360f915b3e6d956 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Mon, 24 Jun 2024 02:25:08 +0400 Subject: [PATCH 1/2] Use AsRef instead of PathBuf in sink_ methods --- crates/polars-lazy/src/frame/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/polars-lazy/src/frame/mod.rs b/crates/polars-lazy/src/frame/mod.rs index c438d169b421..10ab202415ea 100644 --- a/crates/polars-lazy/src/frame/mod.rs +++ b/crates/polars-lazy/src/frame/mod.rs @@ -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::*; @@ -752,10 +752,10 @@ 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, 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()", @@ -787,10 +787,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, 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()", @@ -832,10 +832,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, 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()", @@ -846,10 +846,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, 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()", From ca9470bd7d2f14f6a58636d5d98ffcc5df200b6e Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Mon, 24 Jun 2024 02:29:26 +0400 Subject: [PATCH 2/2] rustfmt --- crates/polars-lazy/src/frame/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/polars-lazy/src/frame/mod.rs b/crates/polars-lazy/src/frame/mod.rs index 10ab202415ea..e9ccc4a6b4b4 100644 --- a/crates/polars-lazy/src/frame/mod.rs +++ b/crates/polars-lazy/src/frame/mod.rs @@ -752,7 +752,11 @@ 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: impl AsRef, options: ParquetWriteOptions) -> PolarsResult<()> { + pub fn sink_parquet( + self, + path: impl AsRef, + options: ParquetWriteOptions, + ) -> PolarsResult<()> { self.sink( SinkType::File { path: Arc::new(path.as_ref().to_path_buf()),