Skip to content

Commit

Permalink
use tmp directory in test
Browse files Browse the repository at this point in the history
  • Loading branch information
2010YOUY01 committed Nov 10, 2023
1 parent 91c9d6f commit 83f3d76
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions datafusion/core/src/execution/context/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
},
Expand All @@ -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()
Expand All @@ -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()
},
Expand All @@ -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()
},
Expand Down

0 comments on commit 83f3d76

Please sign in to comment.