XBaith commented on code in PR #12366:
URL: https://github.com/apache/iceberg/pull/12366#discussion_r1968759987


##########
data/src/main/java/org/apache/iceberg/data/GenericAppenderFactory.java:
##########
@@ -44,41 +46,85 @@
 
 /** Factory to create a new {@link FileAppender} to write {@link Record}s. */
 public class GenericAppenderFactory implements FileAppenderFactory<Record> {
-
+  private final Table table;
   private final Schema schema;
   private final PartitionSpec spec;
   private final int[] equalityFieldIds;
   private final Schema eqDeleteRowSchema;
   private final Schema posDeleteRowSchema;
-  private final Map<String, String> config = Maps.newHashMap();
+  private final Map<String, String> config;
+
+  private static final String WRITE_METRICS_PREFIX = "write.metadata.metrics.";
 
+  @Deprecated
   public GenericAppenderFactory(Schema schema) {
-    this(schema, PartitionSpec.unpartitioned(), null, null, null);
+    this(schema, PartitionSpec.unpartitioned());
   }
 
+  @Deprecated
   public GenericAppenderFactory(Schema schema, PartitionSpec spec) {
     this(schema, spec, null, null, null);
   }
 
+  @Deprecated
   public GenericAppenderFactory(
       Schema schema,
       PartitionSpec spec,
       int[] equalityFieldIds,
       Schema eqDeleteRowSchema,
       Schema posDeleteRowSchema) {
-    this.schema = schema;
-    this.spec = spec;
+    this(null, schema, spec, null, equalityFieldIds, eqDeleteRowSchema, 
posDeleteRowSchema);
+  }
+
+  public GenericAppenderFactory(Table table) {
+    this(table, null, null, null, null, null, null);
+  }
+
+  public GenericAppenderFactory(
+      Table table,
+      Schema schema,
+      PartitionSpec spec,
+      Map<String, String> config,
+      int[] equalityFieldIds,
+      Schema eqDeleteRowSchema,
+      Schema posDeleteRowSchema) {
+    this.table = table;
+    if (table != null && schema == null) {
+      this.schema = table.schema();
+    } else {
+      this.schema = schema;
+    }
+
+    if (table != null && spec == null) {
+      this.spec = table.spec();
+    } else {
+      this.spec = spec;
+    }
+
+    this.config = config == null ? Maps.newHashMap() : config;

Review Comment:
   Got it! Your idea is to fully retain the previously exposed API to ensure 
that user applications remain unaffected by the changes — that makes sense, 
since this class is intended for external use. I’ll revise the code accordingly 
based on the points



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