This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new b582246ce2 Core: Do not produce a partition summary for unpartitioned
writes (#6411)
b582246ce2 is described below
commit b582246ce27c53379c64c013205081c6a65ca325
Author: Eduard Tudenhöfner <[email protected]>
AuthorDate: Mon Dec 19 18:37:13 2022 +0100
Core: Do not produce a partition summary for unpartitioned writes (#6411)
Previously, having an unpartitioned table would produce a `"partitions."`
entry in
the snapshot summary when the partition summary limit was configured
---
.../java/org/apache/iceberg/SnapshotSummary.java | 3 ++-
.../java/org/apache/iceberg/TestFastAppend.java | 31 ++++++++++++++++++++++
.../test/java/org/apache/iceberg/TestRowDelta.java | 3 ---
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/SnapshotSummary.java
b/core/src/main/java/org/apache/iceberg/SnapshotSummary.java
index 460e67430b..e26365b562 100644
--- a/core/src/main/java/org/apache/iceberg/SnapshotSummary.java
+++ b/core/src/main/java/org/apache/iceberg/SnapshotSummary.java
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.iceberg.relocated.com.google.common.base.Joiner;
import org.apache.iceberg.relocated.com.google.common.base.Joiner.MapJoiner;
+import org.apache.iceberg.relocated.com.google.common.base.Strings;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
@@ -194,7 +195,7 @@ public class SnapshotSummary {
setIf(changedPartitions.size() > 0, builder, PARTITION_SUMMARY_PROP,
"true");
for (String key : changedPartitions) {
setIf(
- key != null,
+ !Strings.isNullOrEmpty(key),
builder,
CHANGED_PARTITION_PREFIX + key,
partitionSummary(partitionMetrics.get(key)));
diff --git a/core/src/test/java/org/apache/iceberg/TestFastAppend.java
b/core/src/test/java/org/apache/iceberg/TestFastAppend.java
index ecc673f530..b6b922d41d 100644
--- a/core/src/test/java/org/apache/iceberg/TestFastAppend.java
+++ b/core/src/test/java/org/apache/iceberg/TestFastAppend.java
@@ -27,6 +27,7 @@ import org.apache.iceberg.ManifestEntry.Status;
import org.apache.iceberg.exceptions.CommitFailedException;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.assertj.core.api.Assertions;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -405,6 +406,36 @@ public class TestFastAppend extends TableTestBase {
() ->
table.newFastAppend().appendManifest(manifestWithDeletedFiles).commit());
}
+ @Test
+ public void testPartitionSummariesOnUnpartitionedTable() {
+ Table table =
+ TestTables.create(
+ tableDir,
+ "x",
+ SCHEMA,
+ PartitionSpec.unpartitioned(),
+ SortOrder.unsorted(),
+ formatVersion);
+
+
table.updateProperties().set(TableProperties.WRITE_PARTITION_SUMMARY_LIMIT,
"1").commit();
+ table
+ .newFastAppend()
+ .appendFile(
+ DataFiles.builder(PartitionSpec.unpartitioned())
+ .withPath("/path/to/data-a.parquet")
+ .withFileSizeInBytes(10)
+ .withRecordCount(1)
+ .build())
+ .commit();
+
+ Assertions.assertThat(
+ table.currentSnapshot().summary().keySet().stream()
+ .filter(key ->
key.startsWith(SnapshotSummary.CHANGED_PARTITION_PREFIX))
+ .collect(Collectors.toSet()))
+ .as("Should not include any partition summaries")
+ .isEmpty();
+ }
+
@Test
public void testDefaultPartitionSummaries() {
table.newFastAppend().appendFile(FILE_A).commit();
diff --git a/core/src/test/java/org/apache/iceberg/TestRowDelta.java
b/core/src/test/java/org/apache/iceberg/TestRowDelta.java
index cce58f3e62..4e09316bd1 100644
--- a/core/src/test/java/org/apache/iceberg/TestRowDelta.java
+++ b/core/src/test/java/org/apache/iceberg/TestRowDelta.java
@@ -904,9 +904,6 @@ public class TestRowDelta extends V2TableTestBase {
Assert.assertEquals("Should add 3 position deletes", "3",
summary.get(ADDED_POS_DELETES_PROP));
Assert.assertEquals("Should have 3 position deletes", "3",
summary.get(TOTAL_POS_DELETES_PROP));
- Assert.assertTrue(
- "Partition metrics must be correct",
- summary.get(CHANGED_PARTITION_PREFIX).contains(ADDED_DELETE_FILES_PROP
+ "=1"));
Assert.assertTrue(
"Partition metrics must be correct",
summary