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

Minor: Fix temporary files created but not deleted during testing #8115

Merged
merged 1 commit into from
Nov 11, 2023
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
34 changes: 27 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 @@ -137,6 +138,7 @@ mod tests {
Ok(())
}

#[cfg(not(target_family = "windows"))]
#[tokio::test]
async fn read_from_different_file_extension() -> Result<()> {
let ctx = SessionContext::new();
Expand All @@ -155,11 +157,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 +193,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 +206,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 +219,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 +233,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 +247,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 +262,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