Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): Use AsRef<Path> instead of PathBuf in sink_ methods #17150

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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