You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by si...@apache.org on 2026/07/01 18:22:57 UTC
(iceberg) branch main updated: Core: Include row lineage and key-id in snapshot value methods (#17015)
This is an automated email from the ASF dual-hosted git repository.
singhpk234 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new f1ed57c177 Core: Include row lineage and key-id in snapshot value methods (#17015)
f1ed57c177 is described below
commit f1ed57c1776b7f6cc96e0d434aa6dbdea6407348
Author: Manu Zhang <Ow...@gmail.com>
AuthorDate: Thu Jul 2 02:22:50 2026 +0800
Core: Include row lineage and key-id in snapshot value methods (#17015)
Include snapshot row-lineage fields and manifest list key IDs in BaseSnapshot equals/hashCode and toString. This keeps comparisons and hashes aligned with metadata that changes row ID assignment or manifest-list encryption key selection, and makes those values visible in debug output.
Co-authored-by: Codex <co...@openai.com>
---
.../main/java/org/apache/iceberg/BaseSnapshot.java | 17 ++++++++++--
.../test/java/org/apache/iceberg/TestSnapshot.java | 30 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/BaseSnapshot.java b/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
index b8ea6db229..826b9624c0 100644
--- a/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
+++ b/core/src/main/java/org/apache/iceberg/BaseSnapshot.java
@@ -340,7 +340,10 @@ class BaseSnapshot implements Snapshot {
&& Objects.equal(this.parentId, other.parentId())
&& this.sequenceNumber == other.sequenceNumber()
&& this.timestampMillis == other.timestampMillis()
- && Objects.equal(this.schemaId, other.schemaId());
+ && Objects.equal(this.schemaId, other.schemaId())
+ && Objects.equal(this.firstRowId, other.firstRowId())
+ && Objects.equal(this.addedRows, other.addedRows())
+ && Objects.equal(this.keyId, other.keyId());
}
return false;
@@ -349,7 +352,14 @@ class BaseSnapshot implements Snapshot {
@Override
public int hashCode() {
return Objects.hashCode(
- this.snapshotId, this.parentId, this.sequenceNumber, this.timestampMillis, this.schemaId);
+ this.snapshotId,
+ this.parentId,
+ this.sequenceNumber,
+ this.timestampMillis,
+ this.schemaId,
+ this.firstRowId,
+ this.addedRows,
+ this.keyId);
}
@Override
@@ -361,6 +371,9 @@ class BaseSnapshot implements Snapshot {
.add("summary", summary)
.add("manifest-list", manifestListLocation)
.add("schema-id", schemaId)
+ .add("first-row-id", firstRowId)
+ .add("added-rows", addedRows)
+ .add("key-id", keyId)
.toString();
}
}
diff --git a/core/src/test/java/org/apache/iceberg/TestSnapshot.java b/core/src/test/java/org/apache/iceberg/TestSnapshot.java
index ff9aebffc3..398bce3e94 100644
--- a/core/src/test/java/org/apache/iceberg/TestSnapshot.java
+++ b/core/src/test/java/org/apache/iceberg/TestSnapshot.java
@@ -30,6 +30,36 @@ import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(ParameterizedTestExtension.class)
public class TestSnapshot extends TestBase {
+ @TestTemplate
+ public void snapshotValueMethodsIncludeMetadataFields() {
+ Snapshot snapshot =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 10L, 5L, "key-1");
+ Snapshot same =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 10L, 5L, "key-1");
+ Snapshot differentFirstRowId =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 11L, 5L, "key-1");
+ Snapshot differentAddedRows =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 10L, 6L, "key-1");
+ Snapshot differentKeyId =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 10L, 5L, "key-2");
+ Snapshot withoutMetadataFields =
+ new BaseSnapshot(
+ 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", null, null, null);
+
+ assertThat(snapshot).isEqualTo(same);
+ assertThat(snapshot.hashCode()).isEqualTo(same.hashCode());
+ assertThat(snapshot).isNotEqualTo(differentFirstRowId);
+ assertThat(snapshot).isNotEqualTo(differentAddedRows);
+ assertThat(snapshot).isNotEqualTo(differentKeyId);
+ assertThat(snapshot).isNotEqualTo(withoutMetadataFields);
+ assertThat(snapshot.toString()).contains("first-row-id=10", "added-rows=5", "key-id=key-1");
+ }
+
@TestTemplate
public void testAppendFilesFromTable() {
table.newFastAppend().appendFile(FILE_A).appendFile(FILE_B).commit();