From 8351248150c1750dc17b7b0156eeea8427423ccd Mon Sep 17 00:00:00 2001 From: Eduard Tudenhoefner Date: Wed, 20 Nov 2024 16:17:59 +0100 Subject: [PATCH] implement formatVersion() for PositionDeletesTable --- .../source/SparkPositionDeletesRewrite.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeletesRewrite.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeletesRewrite.java index 034cf6f31f27..e04326c4a280 100644 --- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeletesRewrite.java +++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeletesRewrite.java @@ -22,17 +22,15 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.apache.iceberg.BaseMetadataTable; import org.apache.iceberg.DeleteFile; import org.apache.iceberg.FileFormat; -import org.apache.iceberg.HasTableOperations; import org.apache.iceberg.MetadataColumns; import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.PositionDeletesTable; import org.apache.iceberg.Schema; import org.apache.iceberg.StructLike; import org.apache.iceberg.Table; -import org.apache.iceberg.TableOperations; +import org.apache.iceberg.TableUtil; import org.apache.iceberg.deletes.DeleteGranularity; import org.apache.iceberg.deletes.PositionDelete; import org.apache.iceberg.io.ClusteredPositionDeleteWriter; @@ -350,7 +348,7 @@ private static class DeleteWriter implements DataWriter { this.io = table.io(); this.spec = table.specs().get(specId); this.partition = partition; - this.formatVersion = formatVersion(table); + this.formatVersion = TableUtil.formatVersion(table); this.fileOrdinal = dsSchema.fieldIndex(MetadataColumns.DELETE_FILE_PATH.name()); this.positionOrdinal = dsSchema.fieldIndex(MetadataColumns.DELETE_FILE_POS.name()); @@ -362,17 +360,6 @@ private static class DeleteWriter implements DataWriter { this.rowSize = ((StructType) type).size(); } - private int formatVersion(Table table) { - if (table instanceof BaseMetadataTable) { - return ((BaseMetadataTable) table).table().operations().current().formatVersion(); - } else if (table instanceof HasTableOperations) { - TableOperations ops = ((HasTableOperations) table).operations(); - return ops.current().formatVersion(); - } else { - return 2; - } - } - @Override public void write(InternalRow record) throws IOException { String file = record.getString(fileOrdinal);