Skip to content

Commit

Permalink
keep previous constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
XBaith committed Feb 21, 2025
1 parent d4fe23a commit 00f3e02
Showing 1 changed file with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
import org.apache.iceberg.StructLike;
import org.apache.iceberg.Table;
import org.apache.iceberg.avro.Avro;
import org.apache.iceberg.data.avro.DataWriter;
import org.apache.iceberg.data.orc.GenericOrcWriter;
Expand All @@ -44,30 +45,56 @@

/** 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();

@Deprecated
public GenericAppenderFactory(Schema schema) {
this(schema, PartitionSpec.unpartitioned(), null, null, null);
this(null, schema, PartitionSpec.unpartitioned(), null, null, null);
}

@Deprecated
public GenericAppenderFactory(Schema schema, PartitionSpec spec) {
this(schema, spec, null, null, null);
this(null, schema, spec, null, null, null);
}

@Deprecated
public GenericAppenderFactory(
Schema schema,
PartitionSpec spec,
int[] equalityFieldIds,
Schema eqDeleteRowSchema,
Schema posDeleteRowSchema) {
this(null, schema, spec, equalityFieldIds, eqDeleteRowSchema, posDeleteRowSchema);
}

public GenericAppenderFactory(Table table) {
this(table, null, null, null, null, null);
}

public GenericAppenderFactory(
Table table,
Schema schema,
PartitionSpec spec,
int[] equalityFieldIds,
Schema eqDeleteRowSchema,
Schema posDeleteRowSchema) {
this.schema = schema;
this.spec = spec;
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.equalityFieldIds = equalityFieldIds;
this.eqDeleteRowSchema = eqDeleteRowSchema;
this.posDeleteRowSchema = posDeleteRowSchema;
Expand All @@ -91,7 +118,13 @@ public FileAppender<Record> newAppender(OutputFile outputFile, FileFormat fileFo
@Override
public FileAppender<Record> newAppender(
EncryptedOutputFile encryptedOutputFile, FileFormat fileFormat) {
MetricsConfig metricsConfig = MetricsConfig.fromProperties(config);
MetricsConfig metricsConfig;
if (table == null) {
metricsConfig = MetricsConfig.fromProperties(config);
} else {
metricsConfig = MetricsConfig.forTable(table);
}

try {
switch (fileFormat) {
case AVRO:
Expand Down

0 comments on commit 00f3e02

Please sign in to comment.