From 23c33cf4fd59d230d6616aca6cdd891a3f9a3442 Mon Sep 17 00:00:00 2001 From: ConradJam Date: Tue, 14 Jan 2025 19:47:21 +0800 Subject: [PATCH] [Improvement]: Upgrade to iceberg 1.6.1 (#3084) --- .../optimizing/IcebergRewriteExecutor.java | 13 --------- .../apache/amoro/table/BasicUnkeyedTable.java | 6 ++++ .../apache/iceberg/TestIcebergFindFiles.java | 28 ++++++++++++++++--- .../v1.15/amoro-mixed-flink-1.15/pom.xml | 1 + .../v1.16/amoro-mixed-flink-1.16/pom.xml | 1 + .../v1.17/amoro-mixed-flink-1.17/pom.xml | 1 + .../amoro-mixed-spark-3-common/pom.xml | 3 +- .../v3.2/amoro-mixed-spark-3.2/pom.xml | 1 + .../v3.3/amoro-mixed-spark-3.3/pom.xml | 1 + pom.xml | 6 ++-- 10 files changed, 40 insertions(+), 21 deletions(-) diff --git a/amoro-format-iceberg/src/main/java/org/apache/amoro/optimizing/IcebergRewriteExecutor.java b/amoro-format-iceberg/src/main/java/org/apache/amoro/optimizing/IcebergRewriteExecutor.java index fa355a8bfa..d172221720 100644 --- a/amoro-format-iceberg/src/main/java/org/apache/amoro/optimizing/IcebergRewriteExecutor.java +++ b/amoro-format-iceberg/src/main/java/org/apache/amoro/optimizing/IcebergRewriteExecutor.java @@ -24,7 +24,6 @@ import org.apache.amoro.table.MixedTable; import org.apache.amoro.utils.map.StructLikeCollections; import org.apache.iceberg.PartitionSpec; -import org.apache.iceberg.StructLike; import org.apache.iceberg.TableProperties; import org.apache.iceberg.data.GenericAppenderFactory; import org.apache.iceberg.data.IdentityPartitionConverters; @@ -46,18 +45,6 @@ public IcebergRewriteExecutor( super(input, table, structLikeCollections); } - // TODO We can remove this override method after upgrading Iceberg version to 1.5+. - @Override - protected StructLike partition() { - StructLike partitionData = super.partition(); - if (partitionData != null && partitionData.size() == 0) { - // Cast empty partition data to NULL to avoid creating empty partition directory. - return null; - } else { - return partitionData; - } - } - @Override protected OptimizingDataReader dataReader() { return new GenericCombinedIcebergDataReader( diff --git a/amoro-format-iceberg/src/main/java/org/apache/amoro/table/BasicUnkeyedTable.java b/amoro-format-iceberg/src/main/java/org/apache/amoro/table/BasicUnkeyedTable.java index d5f6f878d4..6c5cceee63 100644 --- a/amoro-format-iceberg/src/main/java/org/apache/amoro/table/BasicUnkeyedTable.java +++ b/amoro-format-iceberg/src/main/java/org/apache/amoro/table/BasicUnkeyedTable.java @@ -65,6 +65,7 @@ import java.util.List; import java.util.Map; +import java.util.UUID; /** Basic implementation of {@link UnkeyedTable}, wrapping a {@link Table}. */ public class BasicUnkeyedTable implements UnkeyedTable, HasTableOperations { @@ -318,4 +319,9 @@ public StructLikeMap> partitionProperty() { public UpdatePartitionProperties updatePartitionProperties(Transaction transaction) { return new PartitionPropertiesUpdate(this, transaction); } + + @Override + public UUID uuid() { + return UUID.fromString(this.operations().current().uuid()); + } } diff --git a/amoro-format-iceberg/src/test/java/org/apache/iceberg/TestIcebergFindFiles.java b/amoro-format-iceberg/src/test/java/org/apache/iceberg/TestIcebergFindFiles.java index bd674c7d3b..e7fa4a37e2 100644 --- a/amoro-format-iceberg/src/test/java/org/apache/iceberg/TestIcebergFindFiles.java +++ b/amoro-format-iceberg/src/test/java/org/apache/iceberg/TestIcebergFindFiles.java @@ -25,24 +25,44 @@ import org.apache.iceberg.expressions.Expressions; import org.apache.iceberg.types.Conversions; import org.apache.iceberg.types.Types; +import org.junit.After; import org.junit.Assert; import org.junit.Assume; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; +import java.util.List; import java.util.Set; @RunWith(Parameterized.class) -public class TestIcebergFindFiles extends TableTestBase { +public class TestIcebergFindFiles extends TestBase { + @Parameterized.Parameters(name = "formatVersion = {0}") - public static Object[] parameters() { - return new Object[] {1, 2}; + public static List parameters() { + return Arrays.asList(1, 2); } + @Rule public TemporaryFolder tempDir = new TemporaryFolder(); + public TestIcebergFindFiles(int formatVersion) { - super(formatVersion); + this.formatVersion = formatVersion; + } + + @Before + public void setUp() throws Exception { + this.tableDir = tempDir.newFolder(); + this.tableDir.delete(); + super.setupTable(); + } + + @After + public void cleanUp() throws Exception { + super.cleanupTables(); } @Test diff --git a/amoro-format-mixed/amoro-mixed-flink/v1.15/amoro-mixed-flink-1.15/pom.xml b/amoro-format-mixed/amoro-mixed-flink/v1.15/amoro-mixed-flink-1.15/pom.xml index 0f9202e688..223f8e7953 100644 --- a/amoro-format-mixed/amoro-mixed-flink/v1.15/amoro-mixed-flink-1.15/pom.xml +++ b/amoro-format-mixed/amoro-mixed-flink/v1.15/amoro-mixed-flink-1.15/pom.xml @@ -34,6 +34,7 @@ jar + 1.4.3 2.8.1 3.21.0 1.17.2 diff --git a/amoro-format-mixed/amoro-mixed-flink/v1.16/amoro-mixed-flink-1.16/pom.xml b/amoro-format-mixed/amoro-mixed-flink/v1.16/amoro-mixed-flink-1.16/pom.xml index cee7422677..c9df28f195 100644 --- a/amoro-format-mixed/amoro-mixed-flink/v1.16/amoro-mixed-flink-1.16/pom.xml +++ b/amoro-format-mixed/amoro-mixed-flink/v1.16/amoro-mixed-flink-1.16/pom.xml @@ -34,6 +34,7 @@ jar + 1.4.3 3.2.3 3.21.0 1.17.2 diff --git a/amoro-format-mixed/amoro-mixed-flink/v1.17/amoro-mixed-flink-1.17/pom.xml b/amoro-format-mixed/amoro-mixed-flink/v1.17/amoro-mixed-flink-1.17/pom.xml index 5fd713cca7..a35993220d 100644 --- a/amoro-format-mixed/amoro-mixed-flink/v1.17/amoro-mixed-flink-1.17/pom.xml +++ b/amoro-format-mixed/amoro-mixed-flink/v1.17/amoro-mixed-flink-1.17/pom.xml @@ -34,6 +34,7 @@ jar + 1.4.3 3.2.3 3.21.0 1.17.2 diff --git a/amoro-format-mixed/amoro-mixed-spark/amoro-mixed-spark-3-common/pom.xml b/amoro-format-mixed/amoro-mixed-spark/amoro-mixed-spark-3-common/pom.xml index dd4fa09950..e3ca631381 100644 --- a/amoro-format-mixed/amoro-mixed-spark/amoro-mixed-spark-3-common/pom.xml +++ b/amoro-format-mixed/amoro-mixed-spark/amoro-mixed-spark-3-common/pom.xml @@ -33,6 +33,7 @@ https://amoro.apache.org + 1.4.3 3.2.4 2.12.15 @@ -144,7 +145,7 @@ org.apache.iceberg - iceberg-spark-3.2_2.12 + iceberg-spark-3.3_2.12 ${iceberg.version} provided diff --git a/amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/pom.xml b/amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/pom.xml index cc4e7a8d3d..e5d5cf6679 100644 --- a/amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/pom.xml +++ b/amoro-format-mixed/amoro-mixed-spark/v3.2/amoro-mixed-spark-3.2/pom.xml @@ -34,6 +34,7 @@ https://amoro.apache.org + 1.4.3 2.3.9 3.2.4 2.12.15 diff --git a/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/pom.xml b/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/pom.xml index 8d6cbff8b4..2dd91e9baa 100644 --- a/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/pom.xml +++ b/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/pom.xml @@ -34,6 +34,7 @@ https://amoro.apache.org + 1.4.3 2.3.9 3.3.2 2.12.15 diff --git a/pom.xml b/pom.xml index 130552a4a7..09f660151f 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ 3.3.2 3.3.1 - 1.4.3 + 1.6.1 0.9.0 3.1.1 3.4.0 @@ -1356,8 +1356,8 @@ 14.0.1 2.3.9 2.10.2 - 3.2.4 - 3.2 + 3.3.3 + 3.3