deniskuzZ commented on code in PR #6856:
URL: https://github.com/apache/hive/pull/6856#discussion_r4245284613


##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/data/FileHelpers.java:
##########
@@ -38,159 +40,180 @@
 import org.apache.iceberg.encryption.EncryptedFiles;
 import org.apache.iceberg.encryption.EncryptedOutputFile;
 import org.apache.iceberg.encryption.EncryptionKeyMetadata;
+import org.apache.iceberg.io.DataWriter;
+import org.apache.iceberg.io.DeleteSchemaUtil;
 import org.apache.iceberg.io.FileAppender;
-import org.apache.iceberg.io.FileAppenderFactory;
 import org.apache.iceberg.io.FileWriterFactory;
 import org.apache.iceberg.io.OutputFile;
 import org.apache.iceberg.io.OutputFileFactory;
+import org.apache.iceberg.parquet.Parquet;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.types.Types;
 import org.apache.iceberg.util.CharSequenceSet;
 import org.apache.iceberg.util.Pair;
 
-import static org.apache.iceberg.TableProperties.DEFAULT_FILE_FORMAT;
-import static org.apache.iceberg.TableProperties.DEFAULT_FILE_FORMAT_DEFAULT;
-
 public class FileHelpers {
   private FileHelpers() {
   }
 
-  public static Pair<DeleteFile, CharSequenceSet> writeDeleteFile(Table table, 
OutputFile out,
-                                                                    
List<Pair<CharSequence, Long>> deletes)
-      throws IOException {
-    return writeDeleteFile(table, out, null, deletes);
-  }
-
-  public static Pair<DeleteFile, CharSequenceSet> writeDeleteFile(Table table, 
OutputFile out, StructLike partition,
-                                                                    
List<Pair<CharSequence, Long>> deletes)
+  public static DeleteFile testOnlyPosDeleteFileWithRow(
+      Table table, OutputFile out, StructLike partition, List<Record> 
posDeleteRecords)
       throws IOException {
-    FileFormat format = defaultFormat(table.properties());
-    FileAppenderFactory<Record> factory = new 
GenericAppenderFactory(table.schema(), table.spec());
+    Schema posDeleteSchema = DeleteSchemaUtil.posDeleteSchema(table.schema());
+    FileAppender<Record> appender =
+        Parquet.write(out)
+            .schema(posDeleteSchema)
+            .createWriterFunc(GenericParquetWriter::create)
+            .metricsConfig(MetricsConfig.forPositionDelete())
+            .overwrite()
+            .build();
+    try (Closeable ignored = appender) {
+      posDeleteRecords.forEach(appender::add);
+    }
 
-    PositionDeleteWriter<Record> writer =
-        factory.newPosDeleteWriter(encrypt(out), format, partition);
-    PositionDelete<Record> posDelete = PositionDelete.create();
-    try (Closeable toClose = writer) {
-      for (Pair<CharSequence, Long> delete : deletes) {
-        writer.write(posDelete.set(delete.first(), delete.second(), null));
-      }
+    FileMetadata.Builder builder =
+        FileMetadata.deleteFileBuilder(table.spec())
+            .ofPositionDeletes()
+            .withFormat(FileFormat.PARQUET)
+            .withPath(out.location())
+            .withFileSizeInBytes(appender.length())
+            .withMetrics(appender.metrics());
+    if (partition != null) {
+      builder.withPartition(partition);
     }
 
-    return Pair.of(writer.toDeleteFile(), writer.referencedDataFiles());
+    return builder.build();
   }
 
-  public static DeleteFile writeDeleteFile(Table table, OutputFile out, 
List<Record> deletes, Schema deleteRowSchema)
-      throws IOException {
-    return writeDeleteFile(table, out, null, deletes, deleteRowSchema);
+  public static Pair<DeleteFile, CharSequenceSet> writeDeleteFile(
+      Table table, OutputFile out, List<Pair<CharSequence, Long>> deletes) 
throws IOException {
+    return writeDeleteFile(table, out, null, deletes);
   }
 
-  public static DeleteFile writeDeleteFile(Table table, OutputFile out, 
StructLike partition,
-                                           List<Record> deletes, Schema 
deleteRowSchema)
+  public static Pair<DeleteFile, CharSequenceSet> writeDeleteFile(
+      Table table, OutputFile out, List<Pair<CharSequence, Long>> deletes, int 
formatVersion)
       throws IOException {
-    FileFormat format = defaultFormat(table.properties());
-    int[] equalityFieldIds = 
deleteRowSchema.columns().stream().mapToInt(Types.NestedField::fieldId).toArray();
-    FileAppenderFactory<Record> factory = new 
GenericAppenderFactory(table.schema(), table.spec(),
-        equalityFieldIds, deleteRowSchema, null);
-
-    EqualityDeleteWriter<Record> writer = 
factory.newEqDeleteWriter(encrypt(out), format, partition);
-    try (Closeable toClose = writer) {
-      writer.write(deletes);
-    }
+    return writeDeleteFile(table, out, null, deletes, formatVersion);
+  }
 
-    return writer.toDeleteFile();
+  public static Pair<DeleteFile, CharSequenceSet> writeDeleteFile(

Review Comment:
   do we need this helper with hardcoded V2?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to