singhpk234 commented on code in PR #16353:
URL: https://github.com/apache/iceberg/pull/16353#discussion_r3532766798


##########
spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestTableEncryption.java:
##########
@@ -222,6 +225,50 @@ public void testInsertAndDelete() {
         sql("SELECT * FROM %s ORDER BY id", tableName));
   }
 
+  @TestTemplate
+  public void testExpireSnapshotsRemovesEncryptionKeys() {
+    sql("INSERT INTO %s VALUES (4, 'd', 4.0)", tableName);
+
+    validationCatalog.initialize(catalogName, catalogConfig);
+    Table table = validationCatalog.loadTable(tableIdent);
+
+    Snapshot current = table.currentSnapshot();
+
+    Snapshot snapshotToExpire =
+        Streams.stream(table.snapshots())
+            .filter(snapshot -> snapshot.parentId() == null)
+            .findFirst()
+            .orElseThrow(() -> new IllegalStateException("Expected a root 
snapshot"));
+
+    assertThat(((HasTableOperations) 
table).operations().current().encryptionKeys())
+        .as("Encryption key for snapshotToExpire is in metadata before 
expiry.")
+        .extracting(EncryptedKey::keyId)
+        .contains(snapshotToExpire.keyId(), current.keyId());
+
+    SparkActions.get()
+        .expireSnapshots(table)
+        .expireSnapshotId(snapshotToExpire.snapshotId())
+        .execute();

Review Comment:
   minor/can be done in follow-up: its would be nice to assert that this 
snapshot is actually expired as well ? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to