This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 39238e685 [core] Return sorted snapshot rows by default (#702)
39238e685 is described below
commit 39238e685bc81042c6915c6aaa2758fe1df879a6
Author: leo65535 <[email protected]>
AuthorDate: Fri Mar 24 11:45:33 2023 +0800
[core] Return sorted snapshot rows by default (#702)
---
.../src/main/java/org/apache/paimon/utils/SnapshotManager.java | 2 ++
.../src/test/java/org/apache/paimon/flink/CatalogTableITCase.java | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
index a8388a740..9d0bf13e7 100644
--- a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
+++ b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.io.Serializable;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@@ -163,6 +164,7 @@ public class SnapshotManager implements Serializable {
public Iterator<Snapshot> snapshots() throws IOException {
return listVersionedFiles(fileIO, snapshotDirectory(), SNAPSHOT_PREFIX)
.map(this::snapshot)
+ .sorted(Comparator.comparingLong(Snapshot::id))
.iterator();
}
diff --git
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java
index d7d94d100..005fc39b2 100644
---
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java
+++
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/CatalogTableITCase.java
@@ -53,8 +53,9 @@ public class CatalogTableITCase extends CatalogITCaseBase {
sql("INSERT INTO T VALUES (3, 4)");
List<Row> result = sql("SELECT snapshot_id, schema_id, commit_kind
FROM T$snapshots");
- assertThat(result)
- .containsExactlyInAnyOrder(Row.of(1L, 0L, "APPEND"),
Row.of(2L, 0L, "APPEND"));
+
+ // check correctness and sequence snapshots.
+ assertThat(result).containsExactly(Row.of(1L, 0L, "APPEND"),
Row.of(2L, 0L, "APPEND"));
}
@Test