Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/java/org/apache/iceberg/SnapshotSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;

Expand Down Expand Up @@ -194,7 +195,7 @@ public Map<String, String> build() {
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)));
Expand Down
31 changes: 31 additions & 0 deletions core/src/test/java/org/apache/iceberg/TestFastAppend.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -405,6 +406,36 @@ public void testInvalidAppendManifest() throws IOException {
() -> 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();
Expand Down
3 changes: 0 additions & 3 deletions core/src/test/java/org/apache/iceberg/TestRowDelta.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,6 @@ public void testAddDeleteFilesMultipleSpecs() {
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"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was in fact checking the entry, which we don't produce anymore:

 "partitions." -> "added-position-delete-files=1,added-delete-files=1,added-files-size=10,added-position-deletes=1"

The summaries map also had the following entries for the 3 partitions:

 "partitions.data_bucket=0" -> "added-position-delete-files=1,added-delete-files=1,added-files-size=10,added-position-deletes=1"
 "partitions.data=abc" -> "added-position-delete-files=1,added-delete-files=1,added-files-size=10,added-position-deletes=1"
 "partitions.data=xyz" -> "added-data-files=1,added-records=1,added-files-size=10"

Assert.assertTrue(
"Partition metrics must be correct",
summary
Expand Down