nastra commented on code in PR #9185:
URL: https://github.com/apache/iceberg/pull/9185#discussion_r1434958256


##########
data/src/test/java/org/apache/iceberg/data/GenAppenderHelper.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.data;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.List;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.AppendFiles;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DataFiles;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.Files;
+import org.apache.iceberg.SnapshotRef;
+import org.apache.iceberg.StructLike;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.io.FileAppender;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.assertj.core.api.Assertions;
+
+/** Helper for appending {@link DataFile} to a table or appending {@link 
Record}s to a table. */
+public class GenAppenderHelper {

Review Comment:
   I don't think we need this class. We can just update `GenericAppenderHelper` 
to work with JUnit4's `TemporaryFolder` and JUnit5's `Path` by applying this 
patch:
   
   ```
   diff --git 
a/data/src/test/java/org/apache/iceberg/data/GenericAppenderHelper.java 
b/data/src/test/java/org/apache/iceberg/data/GenericAppenderHelper.java
   index beccc8bb7..8521004ca 100644
   --- a/data/src/test/java/org/apache/iceberg/data/GenericAppenderHelper.java
   +++ b/data/src/test/java/org/apache/iceberg/data/GenericAppenderHelper.java
   @@ -20,6 +20,7 @@ package org.apache.iceberg.data;
    
    import java.io.File;
    import java.io.IOException;
   +import java.nio.file.Path;
    import java.util.List;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.iceberg.AppendFiles;
   @@ -44,13 +45,24 @@ public class GenericAppenderHelper {
      private final Table table;
      private final FileFormat fileFormat;
      private final TemporaryFolder tmp;
   +  private final Path temp;
      private final Configuration conf;
    
   +  @Deprecated
      public GenericAppenderHelper(
          Table table, FileFormat fileFormat, TemporaryFolder tmp, 
Configuration conf) {
        this.table = table;
        this.fileFormat = fileFormat;
        this.tmp = tmp;
   +    this.temp = null;
   +    this.conf = conf;
   +  }
   +
   +  public GenericAppenderHelper(Table table, FileFormat fileFormat, Path 
temp, Configuration conf) {
   +    this.table = table;
   +    this.fileFormat = fileFormat;
   +    this.tmp = null;
   +    this.temp = temp;
        this.conf = conf;
      }
    
   @@ -94,14 +106,14 @@ public class GenericAppenderHelper {
    
      public DataFile writeFile(List<Record> records) throws IOException {
        Preconditions.checkNotNull(table, "table not set");
   -    File file = tmp.newFile();
   +    File file = null != tmp ? tmp.newFile() : File.createTempFile("junit", 
null, temp.toFile());
        Assert.assertTrue(file.delete());
        return appendToLocalFile(table, file, fileFormat, null, records, conf);
      }
    
      public DataFile writeFile(StructLike partition, List<Record> records) 
throws IOException {
        Preconditions.checkNotNull(table, "table not set");
   -    File file = tmp.newFile();
   +    File file = null != tmp ? tmp.newFile() : File.createTempFile("junit", 
null, temp.toFile());
        Assert.assertTrue(file.delete());
        return appendToLocalFile(table, file, fileFormat, partition, records, 
conf);
      }
   ```
   that way we don't have to maintain two files.
   
   @cgpoh can you please remove `GenAppenderHelper` and apply the Assert -> 
AssertJ conversions to `GenericAppenderHelper`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to