This is an automated email from the ASF dual-hosted git repository.

Fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new aa8636205b Core: Remove redundant `tempDir` method (#18787)
aa8636205b is described below

commit aa8636205b583244f8ac7897dd2d44bd23372760
Author: Yuya Ebihara <[email protected]>
AuthorDate: Mon Nov 23 05:42:13 2026 +0900

    Core: Remove redundant `tempDir` method (#18787)
---
 .../iceberg/PartitionStatisticsScanTestBase.java   | 81 +++++-----------------
 .../iceberg/PartitionStatisticsTestBase.java       |  7 +-
 .../iceberg/PartitionStatsHandlerTestBase.java     | 31 ++++-----
 3 files changed, 31 insertions(+), 88 deletions(-)

diff --git 
a/core/src/test/java/org/apache/iceberg/PartitionStatisticsScanTestBase.java 
b/core/src/test/java/org/apache/iceberg/PartitionStatisticsScanTestBase.java
index 4247e0d071..bd9b1a1060 100644
--- a/core/src/test/java/org/apache/iceberg/PartitionStatisticsScanTestBase.java
+++ b/core/src/test/java/org/apache/iceberg/PartitionStatisticsScanTestBase.java
@@ -45,24 +45,17 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
       ImmutableMap.of(TableProperties.DEFAULT_FILE_FORMAT, format().name());
 
   @Test
-  public void testEmptyTable() throws Exception {
+  public void testEmptyTable() {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_empty_table"), "scan_empty_table", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "scan_empty_table", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     
assertThat(Lists.newArrayList(testTable.newPartitionStatisticsScan().scan())).isEmpty();
   }
 
   @Test
-  public void testInvalidSnapshotId() throws Exception {
+  public void testInvalidSnapshotId() {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_invalid_snapshot"),
-            "scan_invalid_snapshot",
-            SCHEMA,
-            SPEC,
-            2,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_invalid_snapshot", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     assertThatThrownBy(() -> 
testTable.newPartitionStatisticsScan().useSnapshot(1234L).scan())
         .isInstanceOf(IllegalArgumentException.class)
@@ -70,10 +63,9 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   }
 
   @Test
-  public void testNoStatsForSnapshot() throws Exception {
+  public void testNoStatsForSnapshot() {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_no_stats"), "scan_no_stats", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "scan_no_stats", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     DataFile dataFile =
         DataFiles.builder(SPEC)
@@ -92,13 +84,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   public void testReadingStatsWithInvalidSchema() throws Exception {
     PartitionSpec spec = 
PartitionSpec.builderFor(SCHEMA).identity("c1").build();
     Table testTable =
-        TestTables.create(
-            tempDir("scan_with_old_schema"),
-            "scan_with_old_schema",
-            SCHEMA,
-            spec,
-            2,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_with_old_schema", SCHEMA, spec, 2, 
fileFormatProperty);
     Types.StructType partitionType = Partitioning.partitionType(testTable);
     Schema oldSchema = invalidOldSchema(partitionType);
 
@@ -142,12 +128,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   public void testV2toV3SchemaEvolution() throws Exception {
     Table testTable =
         TestTables.create(
-            tempDir("scan_with_schema_evolution"),
-            "scan_with_schema_evolution",
-            SCHEMA,
-            SPEC,
-            2,
-            fileFormatProperty);
+            tempDir, "scan_with_schema_evolution", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     // write stats file using v2 schema
     DataFile dataFile =
@@ -190,13 +171,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   @Test
   public void testScanPartitionStatsForCurrentSnapshot() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_partition_stats"),
-            "scan_partition_stats",
-            SCHEMA,
-            SPEC,
-            2,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_partition_stats", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     DataFile dataFile1 =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -362,13 +337,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   @Test
   public void testScanPartitionStatsForOlderSnapshot() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_older_snapshot"),
-            "scan_older_snapshot",
-            SCHEMA,
-            SPEC,
-            2,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_older_snapshot", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     DataFile dataFile1 =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -422,13 +391,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   @Test
   public void testProjectStatFields() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_project_subset"),
-            "scan_project_subset",
-            SCHEMA,
-            SPEC,
-            3,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_project_subset", SCHEMA, SPEC, 3, 
fileFormatProperty);
 
     DataFile dataFile1 =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -487,10 +450,9 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   }
 
   @Test
-  public void testProjectNullSchemaIsRejected() throws Exception {
+  public void testProjectNullSchemaIsRejected() {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_project_null"), "scan_project_null", SCHEMA, SPEC, 
2, fileFormatProperty);
+        TestTables.create(tempDir, "scan_project_null", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     assertThatThrownBy(() -> 
testTable.newPartitionStatisticsScan().project(null))
         .isInstanceOf(IllegalArgumentException.class)
@@ -500,13 +462,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   @Test
   public void testProjectIgnoresUnknownField() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_project_unknown"),
-            "scan_project_unknown",
-            SCHEMA,
-            SPEC,
-            3,
-            fileFormatProperty);
+        TestTables.create(tempDir, "scan_project_unknown", SCHEMA, SPEC, 3, 
fileFormatProperty);
 
     DataFile dataFile1 =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -560,10 +516,9 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   }
 
   @Test
-  public void testNullFilter() throws Exception {
+  public void testNullFilter() {
     Table testTable =
-        TestTables.create(
-            tempDir("scan_filter_null"), "scan_filter_null", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "scan_filter_null", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     assertThatThrownBy(() -> 
testTable.newPartitionStatisticsScan().filter(null))
         .isInstanceOf(IllegalArgumentException.class)
@@ -825,7 +780,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   }
 
   private Table tableWithTwoPartitions(String name) throws IOException {
-    Table testTable = TestTables.create(tempDir(name), name, SCHEMA, SPEC, 2, 
fileFormatProperty);
+    Table testTable = TestTables.create(tempDir, name, SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     DataFile dataFile1 =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -843,7 +798,7 @@ public abstract class PartitionStatisticsScanTestBase 
extends PartitionStatistic
   }
 
   private Table tableWithUnevenPartitions(String name) throws IOException {
-    Table testTable = TestTables.create(tempDir(name), name, SCHEMA, SPEC, 2, 
fileFormatProperty);
+    Table testTable = TestTables.create(tempDir, name, SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     for (int i = 0; i < 3; i++) {
       testTable
diff --git 
a/core/src/test/java/org/apache/iceberg/PartitionStatisticsTestBase.java 
b/core/src/test/java/org/apache/iceberg/PartitionStatisticsTestBase.java
index 518c1b3cde..242fbdd82a 100644
--- a/core/src/test/java/org/apache/iceberg/PartitionStatisticsTestBase.java
+++ b/core/src/test/java/org/apache/iceberg/PartitionStatisticsTestBase.java
@@ -33,7 +33,6 @@ import static 
org.apache.iceberg.PartitionStatistics.TOTAL_RECORD_COUNT;
 import static org.apache.iceberg.types.Types.NestedField.optional;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Comparator;
 import java.util.Objects;
 import java.util.Random;
@@ -44,7 +43,7 @@ import org.junit.jupiter.api.io.TempDir;
 
 public abstract class PartitionStatisticsTestBase {
 
-  @TempDir private File temp;
+  @TempDir protected File tempDir;
 
   protected static final Schema SCHEMA =
       new Schema(
@@ -90,10 +89,6 @@ public abstract class PartitionStatisticsTestBase {
     return stats;
   }
 
-  protected File tempDir(String folderName) throws IOException {
-    return java.nio.file.Files.createTempDirectory(temp.toPath(), 
folderName).toFile();
-  }
-
   protected static StructLike partitionRecord(
       Types.StructType partitionType, String val1, String val2) {
     GenericRecord record = GenericRecord.create(partitionType);
diff --git 
a/core/src/test/java/org/apache/iceberg/PartitionStatsHandlerTestBase.java 
b/core/src/test/java/org/apache/iceberg/PartitionStatsHandlerTestBase.java
index d4a2e8ec64..cf630f4322 100644
--- a/core/src/test/java/org/apache/iceberg/PartitionStatsHandlerTestBase.java
+++ b/core/src/test/java/org/apache/iceberg/PartitionStatsHandlerTestBase.java
@@ -65,36 +65,33 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
   @Test
   public void testPartitionStatsOnEmptyTable() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("empty_table"), "empty_table", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "empty_table", SCHEMA, SPEC, 2, 
fileFormatProperty);
     
assertThat(PartitionStatsHandler.computeAndWriteStatsFile(testTable)).isNull();
   }
 
   @Test
   public void testPartitionStatsOnEmptyBranch() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("empty_branch"), "empty_branch", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "empty_branch", SCHEMA, SPEC, 2, 
fileFormatProperty);
     testTable.manageSnapshots().createBranch("b1").commit();
     long branchSnapshot = testTable.refs().get("b1").snapshotId();
     assertThat(PartitionStatsHandler.computeAndWriteStatsFile(testTable, 
branchSnapshot)).isNull();
   }
 
   @Test
-  public void testPartitionStatsOnInvalidSnapshot() throws Exception {
+  public void testPartitionStatsOnInvalidSnapshot() {
     Table testTable =
-        TestTables.create(
-            tempDir("invalid_snapshot"), "invalid_snapshot", SCHEMA, SPEC, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "invalid_snapshot", SCHEMA, SPEC, 2, 
fileFormatProperty);
     assertThatThrownBy(() -> 
PartitionStatsHandler.computeAndWriteStatsFile(testTable, 42L))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessage("Snapshot not found: 42");
   }
 
   @Test
-  public void testPartitionStatsOnUnPartitionedTable() throws Exception {
+  public void testPartitionStatsOnUnPartitionedTable() {
     Table testTable =
         TestTables.create(
-            tempDir("unpartitioned_table"),
+            tempDir,
             "unpartitioned_table",
             SCHEMA,
             PartitionSpec.unpartitioned(),
@@ -152,7 +149,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
 
     Table testTable =
         TestTables.create(
-            tempDir("test_all_type_" + formatVersion),
+            tempDir,
             "test_all_type_" + formatVersion,
             schema,
             spec,
@@ -222,7 +219,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
     PartitionSpec spec = 
PartitionSpec.builderFor(SCHEMA).identity("c1").build();
     Table testTable =
         TestTables.create(
-            tempDir("test_partition_stats_optional_" + formatVersion),
+            tempDir,
             "test_partition_stats_optional_" + formatVersion,
             SCHEMA,
             spec,
@@ -297,8 +294,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
 
   @Test
   public void testCopyOnWriteDelete() throws Exception {
-    Table testTable =
-        TestTables.create(tempDir("my_test"), "my_test", SCHEMA, SPEC, 2, 
fileFormatProperty);
+    Table testTable = TestTables.create(tempDir, "my_test", SCHEMA, SPEC, 2, 
fileFormatProperty);
 
     DataFile dataFile1 =
         DataFiles.builder(SPEC)
@@ -340,8 +336,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
 
   @Test
   public void testLatestStatsFile() throws Exception {
-    Table testTable =
-        TestTables.create(tempDir("stats_file"), "stats_file", SCHEMA, SPEC, 
2, fileFormatProperty);
+    Table testTable = TestTables.create(tempDir, "stats_file", SCHEMA, SPEC, 
2, fileFormatProperty);
 
     DataFile dataFile =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
@@ -376,8 +371,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
   @Test
   public void testLatestStatsFileWithBranch() throws Exception {
     Table testTable =
-        TestTables.create(
-            tempDir("stats_file_branch"), "stats_file_branch", SCHEMA, SPEC, 
2, fileFormatProperty);
+        TestTables.create(tempDir, "stats_file_branch", SCHEMA, SPEC, 2, 
fileFormatProperty);
     DataFile dataFile =
         FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
 
@@ -417,8 +411,7 @@ public abstract class PartitionStatsHandlerTestBase extends 
PartitionStatisticsT
   public void testFullComputeFallbackWithInvalidStats() throws Exception {
     PartitionSpec spec = 
PartitionSpec.builderFor(SCHEMA).identity("c1").build();
     Table testTable =
-        TestTables.create(
-            tempDir("invalid_schema"), "invalid_schema", SCHEMA, spec, 2, 
fileFormatProperty);
+        TestTables.create(tempDir, "invalid_schema", SCHEMA, spec, 2, 
fileFormatProperty);
     DataFile dataFile = FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of(42));
     testTable.newAppend().appendFile(dataFile).commit();
 

Reply via email to