Skip to content

Commit

Permalink
[core] Add tests for drop stats for overwrite commit (#4600)
Browse files Browse the repository at this point in the history
  • Loading branch information
LsomeYeah authored Nov 27, 2024
1 parent 0185f7c commit a79b08b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.index.IndexFileHandler;
import org.apache.paimon.index.IndexFileMeta;
import org.apache.paimon.manifest.FileKind;
import org.apache.paimon.manifest.IndexManifestEntry;
import org.apache.paimon.manifest.ManifestCommittable;
import org.apache.paimon.manifest.ManifestEntry;
import org.apache.paimon.manifest.ManifestFile;
import org.apache.paimon.manifest.ManifestFileMeta;
import org.apache.paimon.mergetree.compact.DeduplicateMergeFunction;
import org.apache.paimon.predicate.PredicateBuilder;
Expand Down Expand Up @@ -80,6 +83,7 @@

import static org.apache.paimon.index.HashIndexFile.HASH_INDEX;
import static org.apache.paimon.partition.PartitionPredicate.createPartitionPredicate;
import static org.apache.paimon.stats.SimpleStats.EMPTY_STATS;
import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -943,6 +947,31 @@ public void testManifestCompact() throws Exception {
.isEqualTo(0);
}

@Test
public void testDropStatsForOverwrite() throws Exception {
TestFileStore store = createStore(false);

List<KeyValue> keyValues = generateDataList(1);
BinaryRow partition = gen.getPartition(keyValues.get(0));
// commit 1
Snapshot snapshot1 =
store.commitData(keyValues, s -> partition, kv -> 0, Collections.emptyMap()).get(0);
// overwrite commit 2
Snapshot snapshot2 =
store.overwriteData(keyValues, s -> partition, kv -> 0, Collections.emptyMap())
.get(0);
ManifestFile manifestFile = store.manifestFileFactory().create();
List<ManifestEntry> entries =
store.manifestListFactory().create().readDataManifests(snapshot2).stream()
.flatMap(meta -> manifestFile.read(meta.fileName()).stream())
.collect(Collectors.toList());
for (ManifestEntry manifestEntry : entries) {
if (manifestEntry.kind() == FileKind.DELETE) {
assertThat(manifestEntry.file().valueStats()).isEqualTo(EMPTY_STATS);
}
}
}

@Test
public void testManifestCompactFull() throws Exception {
// Disable full compaction by options.
Expand Down

0 comments on commit a79b08b

Please sign in to comment.