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


##########
data/src/main/java/org/apache/iceberg/data/GenericFileWriterFactory.java:
##########
@@ -107,64 +132,169 @@ public class GenericFileWriterFactory extends 
BaseFileWriterFactory<Record> {
     super(
         table,
         dataFileFormat,
+        Record.class,
         dataSchema,
         dataSortOrder,
         deleteFileFormat,
         equalityFieldIds,
         equalityDeleteRowSchema,
         equalityDeleteSortOrder,
-        positionDeleteRowSchema);
+        ImmutableMap.of(),
+        dataSchema,
+        equalityDeleteRowSchema);
+    this.table = table;
+    this.format = dataFileFormat;
+    this.positionDeleteRowSchema = positionDeleteRowSchema;
   }
 
   static Builder builderFor(Table table) {
     return new Builder(table);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureDataWrite(Avro.DataWriteBuilder builder) {
     builder.createWriterFunc(DataWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureEqualityDelete(Avro.DeleteWriteBuilder builder) {
     builder.createWriterFunc(DataWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configurePositionDelete(Avro.DeleteWriteBuilder builder) {
     builder.createWriterFunc(DataWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureDataWrite(Parquet.DataWriteBuilder builder) {
     builder.createWriterFunc(GenericParquetWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureEqualityDelete(Parquet.DeleteWriteBuilder builder) {
     builder.createWriterFunc(GenericParquetWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configurePositionDelete(Parquet.DeleteWriteBuilder builder) {
     builder.createWriterFunc(GenericParquetWriter::create);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureDataWrite(ORC.DataWriteBuilder builder) {
     builder.createWriterFunc(GenericOrcWriter::buildWriter);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configureEqualityDelete(ORC.DeleteWriteBuilder builder) {
     builder.createWriterFunc(GenericOrcWriter::buildWriter);
   }
 
-  @Override
+  /**
+   * @deprecated Since 1.11.0, will be removed in 1.12.0. It won't be called 
starting in 1.11.0 as
+   *     the configuration is done by the {@link FormatModelRegistry}.
+   */
+  @Deprecated
   protected void configurePositionDelete(ORC.DeleteWriteBuilder builder) {
     builder.createWriterFunc(GenericOrcWriter::buildWriter);
   }
 
+  @Override
+  public PositionDeleteWriter<Record> newPositionDeleteWriter(
+      EncryptedOutputFile file, PartitionSpec spec, StructLike partition) {
+    if (positionDeleteRowSchema == null) {
+      return super.newPositionDeleteWriter(file, spec, partition);
+    } else {
+      LOG.warn(
+          "Deprecated feature used. Position delete row schema is used to 
create the position delete writer.");
+      Map<String, String> properties = table == null ? ImmutableMap.of() : 
table.properties();
+      MetricsConfig metricsConfig =
+          table == null
+              ? MetricsConfig.forPositionDelete()
+              : MetricsConfig.forPositionDelete(table);
+
+      try {
+        return switch (format) {
+          case AVRO ->
+              Avro.writeDeletes(file)
+                  .setAll(properties)
+                  .setAll(writerProperties)
+                  .metricsConfig(metricsConfig)
+                  .createWriterFunc(DataWriter::create)
+                  .withPartition(partition)
+                  .overwrite()
+                  .rowSchema(positionDeleteRowSchema)
+                  .withSpec(spec)
+                  .withKeyMetadata(file.keyMetadata())
+                  .buildPositionWriter();
+          case ORC ->
+              ORC.writeDeletes(file)
+                  .setAll(properties)
+                  .setAll(writerProperties)
+                  .metricsConfig(metricsConfig)
+                  .createWriterFunc(GenericOrcWriter::buildWriter)
+                  .withPartition(partition)
+                  .overwrite()
+                  .rowSchema(positionDeleteRowSchema)
+                  .withSpec(spec)
+                  .withKeyMetadata(file.keyMetadata())
+                  .buildPositionWriter();
+          case PARQUET ->
+              Parquet.writeDeletes(file)
+                  .setAll(properties)
+                  .setAll(writerProperties)
+                  .metricsConfig(metricsConfig)
+                  .createWriterFunc(GenericParquetWriter::create)
+                  .withPartition(partition)
+                  .overwrite()
+                  .metricsConfig(metricsConfig)

Review Comment:
   metricsConfig is set twice here



-- 
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