Skip to content

Apache DataFusion SQL Query Engine

Fix temp dir leak in tests (#16094)

Piotr Findeisen8be2ea54ff43
diff --git a/Cargo.lock b/Cargo.lock
index 54eaff54a7..7f9087e038 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2840,7 +2840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -3724,7 +3724,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
dependencies = [
"hermit-abi",
"libc",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -3932,7 +3932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
- "windows-targets 0.52.6",
+ "windows-targets 0.48.5",
]
[[package]]
@@ -5035,7 +5035,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -5462,7 +5462,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.4.15",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -5475,7 +5475,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.9.2",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -5956,7 +5956,7 @@ dependencies = [
"cfg-if",
"libc",
"psm",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -6182,15 +6182,15 @@ checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
[[package]]
name = "tempfile"
-version = "3.19.1"
+version = "3.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
+checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
dependencies = [
"fastrand",
"getrandom 0.3.1",
"once_cell",
"rustix 1.0.2",
- "windows-sys 0.59.0",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -7115,7 +7115,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
- "windows-sys 0.59.0",
+ "windows-sys 0.48.0",
]
[[package]]
diff --git a/datafusion/core/src/datasource/listing/table.rs b/datafusion/core/src/datasource/listing/table.rs
index 61e34baebe..26daa88c9e 100644
--- a/datafusion/core/src/datasource/listing/table.rs
+++ b/datafusion/core/src/datasource/listing/table.rs
@@ -2383,8 +2383,10 @@ mod tests {
// create table
let tmp_dir = TempDir::new()?;
- let tmp_path = tmp_dir.into_path();
- let str_path = tmp_path.to_str().expect("Temp path should convert to &str");
+ let str_path = tmp_dir
+ .path()
+ .to_str()
+ .expect("Temp path should convert to &str");
session_ctx
.sql(&format!(
"create external table foo(a varchar, b varchar, c int) \
diff --git a/datafusion/core/tests/memory_limit/mod.rs b/datafusion/core/tests/memory_limit/mod.rs
index cf835ac1a5..3d0dc0b60e 100644
--- a/datafusion/core/tests/memory_limit/mod.rs
+++ b/datafusion/core/tests/memory_limit/mod.rs
@@ -354,7 +354,7 @@ async fn oom_recursive_cte() {
#[tokio::test]
async fn oom_parquet_sink() {
let dir = tempfile::tempdir().unwrap();
- let path = dir.into_path().join("test.parquet");
+ let path = dir.path().join("test.parquet");
let _ = File::create(path.clone()).await.unwrap();
TestCase::new()
@@ -378,7 +378,7 @@ async fn oom_parquet_sink() {
#[tokio::test]
async fn oom_with_tracked_consumer_pool() {
let dir = tempfile::tempdir().unwrap();
- let path = dir.into_path().join("test.parquet");
+ let path = dir.path().join("test.parquet");
let _ = File::create(path.clone()).await.unwrap();
TestCase::new()
diff --git a/datafusion/core/tests/parquet/file_statistics.rs b/datafusion/core/tests/parquet/file_statistics.rs
index db1c78cb1d..a038d414cb 100644
--- a/datafusion/core/tests/parquet/file_statistics.rs
+++ b/datafusion/core/tests/parquet/file_statistics.rs
@@ -167,20 +167,12 @@ async fn list_files_with_session_level_cache() {
let testdata = datafusion::test_util::parquet_test_data();
let filename = format!("{testdata}/{p_name}");
- let temp_path1 = tempdir()
- .unwrap()
- .into_path()
- .into_os_string()
- .into_string()
- .unwrap();
+ let temp_dir1 = tempdir().unwrap();
+ let temp_path1 = temp_dir1.path().to_str().unwrap();
let temp_filename1 = format!("{temp_path1}/{p_name}");
- let temp_path2 = tempdir()
- .unwrap()
- .into_path()
- .into_os_string()
- .into_string()
- .unwrap();
+ let temp_dir2 = tempdir().unwrap();
+ let temp_path2 = temp_dir2.path().to_str().unwrap();
let temp_filename2 = format!("{temp_path2}/{p_name}");
fs::copy(filename.clone(), temp_filename1).expect("panic");