This is an automated email from the ASF dual-hosted git repository. jinsongzhou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/amoro.git
commit daa0c49a83f2d768d488acbf53225812bd410c34 Author: xuyu <[email protected]> AuthorDate: Tue Aug 19 10:34:25 2025 +0800 [AMORO-3734][Improvement]: Add operation/schemaId to Snapshot --- .../main/java/org/apache/amoro/TableSnapshot.java | 6 +++++ .../amoro/formats/iceberg/IcebergSnapshot.java | 10 ++++++++ .../apache/amoro/formats/mixed/MixedSnapshot.java | 29 +++++++++++++++++++--- .../amoro/formats/paimon/PaimonSnapshot.java | 10 ++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/amoro-common/src/main/java/org/apache/amoro/TableSnapshot.java b/amoro-common/src/main/java/org/apache/amoro/TableSnapshot.java index 2ed1b1030..f57c34746 100644 --- a/amoro-common/src/main/java/org/apache/amoro/TableSnapshot.java +++ b/amoro-common/src/main/java/org/apache/amoro/TableSnapshot.java @@ -28,4 +28,10 @@ public interface TableSnapshot { /** Returns the id of this snapshot. */ String id(); + + /** Returns the operation of this snapshot. */ + String operation(); + + /** Returns the schema id of this snapshot. */ + long schemaId(); } diff --git a/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/iceberg/IcebergSnapshot.java b/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/iceberg/IcebergSnapshot.java index e90fd6eab..4751e754f 100644 --- a/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/iceberg/IcebergSnapshot.java +++ b/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/iceberg/IcebergSnapshot.java @@ -43,6 +43,16 @@ public class IcebergSnapshot implements TableSnapshot { return String.valueOf(snapshot.snapshotId()); } + @Override + public String operation() { + return snapshot.operation(); + } + + @Override + public long schemaId() { + return snapshot.schemaId(); + } + public Snapshot icebergSnapshot() { return snapshot; } diff --git a/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/mixed/MixedSnapshot.java b/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/mixed/MixedSnapshot.java index 2059d2567..e207e5e29 100644 --- a/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/mixed/MixedSnapshot.java +++ b/amoro-format-iceberg/src/main/java/org/apache/amoro/formats/mixed/MixedSnapshot.java @@ -42,10 +42,15 @@ public class MixedSnapshot implements TableSnapshot { @Override public long commitTime() { - Long changCommit = - Optional.ofNullable(changeSnapshot).map(Snapshot::timestampMillis).orElse(-1L); - Long baseCommit = Optional.ofNullable(baseSnapshot).map(Snapshot::timestampMillis).orElse(-1L); - return Longs.max(changCommit, baseCommit); + return Longs.max(getChangeCommit(), getBaseCommit()); + } + + public long getChangeCommit() { + return Optional.ofNullable(changeSnapshot).map(Snapshot::timestampMillis).orElse(-1L); + } + + public long getBaseCommit() { + return Optional.ofNullable(baseSnapshot).map(Snapshot::timestampMillis).orElse(-1L); } public Snapshot getChangeSnapshot() { @@ -68,4 +73,20 @@ public class MixedSnapshot implements TableSnapshot { public String id() { return changeSnapshot + "_" + baseSnapshot; } + + @Override + public String operation() { + if (getChangeCommit() >= getBaseCommit()) { + return changeSnapshot.operation(); + } + return baseSnapshot.operation(); + } + + @Override + public long schemaId() { + if (getChangeCommit() >= getBaseCommit()) { + return changeSnapshot.schemaId(); + } + return baseSnapshot.schemaId(); + } } diff --git a/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonSnapshot.java b/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonSnapshot.java index 52c0a369d..cd28ced67 100644 --- a/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonSnapshot.java +++ b/amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonSnapshot.java @@ -44,4 +44,14 @@ public class PaimonSnapshot implements TableSnapshot { public String id() { return String.valueOf(snapshot.id()); } + + @Override + public String operation() { + return snapshot.commitKind().toString(); + } + + @Override + public long schemaId() { + return snapshot.schemaId(); + } }
