From 83f3d76b597168381d77bf3667651975ebe132f5 Mon Sep 17 00:00:00 2001 From: Yongting You <2010youy01@gmail.com> Date: Thu, 9 Nov 2023 18:06:44 -0800 Subject: [PATCH] use tmp directory in test --- .../core/src/execution/context/parquet.rs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/datafusion/core/src/execution/context/parquet.rs b/datafusion/core/src/execution/context/parquet.rs index ef1f0143543d8..87b4b92f6fad3 100644 --- a/datafusion/core/src/execution/context/parquet.rs +++ b/datafusion/core/src/execution/context/parquet.rs @@ -80,6 +80,7 @@ mod tests { use crate::dataframe::DataFrameWriteOptions; use crate::parquet::basic::Compression; use crate::test_util::parquet_test_data; + use tempfile::tempdir; use super::*; @@ -155,11 +156,29 @@ mod tests { ], )?)?; + let temp_dir = tempdir()?; + let temp_dir_path = temp_dir.path(); + let path1 = temp_dir_path + .join("output1.parquet") + .to_str() + .unwrap() + .to_string(); + let path2 = temp_dir_path + .join("output2.parquet.snappy") + .to_str() + .unwrap() + .to_string(); + let path3 = temp_dir_path + .join("output3.parquet.snappy.parquet") + .to_str() + .unwrap() + .to_string(); + // Write the dataframe to a parquet file named 'output1.parquet' write_df .clone() .write_parquet( - "output1.parquet", + &path1, DataFrameWriteOptions::new().with_single_file_output(true), Some( WriterProperties::builder() @@ -173,7 +192,7 @@ mod tests { write_df .clone() .write_parquet( - "output2.parquet.snappy", + &path2, DataFrameWriteOptions::new().with_single_file_output(true), Some( WriterProperties::builder() @@ -186,7 +205,7 @@ mod tests { // Write the dataframe to a parquet file named 'output3.parquet.snappy.parquet' write_df .write_parquet( - "output3.parquet.snappy.parquet", + &path3, DataFrameWriteOptions::new().with_single_file_output(true), Some( WriterProperties::builder() @@ -199,7 +218,7 @@ mod tests { // Read the dataframe from 'output1.parquet' with the default file extension. let read_df = ctx .read_parquet( - "output1.parquet", + &path1, ParquetReadOptions { ..Default::default() }, @@ -213,7 +232,7 @@ mod tests { // Read the dataframe from 'output2.parquet.snappy' with the correct file extension. let read_df = ctx .read_parquet( - "output2.parquet.snappy", + &path2, ParquetReadOptions { file_extension: "snappy", ..Default::default() @@ -227,7 +246,7 @@ mod tests { // Read the dataframe from 'output3.parquet.snappy.parquet' with the wrong file extension. let read_df = ctx .read_parquet( - "output2.parquet.snappy", + &path2, ParquetReadOptions { ..Default::default() }, @@ -242,7 +261,7 @@ mod tests { // Read the dataframe from 'output3.parquet.snappy.parquet' with the correct file extension. let read_df = ctx .read_parquet( - "output3.parquet.snappy.parquet", + &path3, ParquetReadOptions { ..Default::default() },