smaheshwar-pltr commented on code in PR #18798:
URL: https://github.com/apache/iceberg/pull/18798#discussion_r4473653365


##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/sql/TestTableEncryption.java:
##########
@@ -305,6 +312,63 @@ public void testKeyAlter() {
         .hasMessage("Unsupported table change: Cannot modify key ID of an 
encrypted table");
   }
 
+  @TestTemplate
+  public void testRejectedKeyIdOnUnencryptedTable() {
+    String unencryptedTable = tableName(UNENCRYPTED_TABLE);
+    sql(
+        "CREATE TABLE %s (id bigint) USING iceberg TBLPROPERTIES 
('format-version'='3')",
+        unencryptedTable);
+
+    assertThatThrownBy(
+            () ->
+                sql(
+                    "ALTER TABLE %s SET TBLPROPERTIES 
('encryption.key-id'='%s')",
+                    unencryptedTable, UnitestKMS.MASTER_KEY_NAME1))
+        .isInstanceOf(SparkException.class)
+        .hasMessage("Unsupported table change: Cannot modify key ID of an 
encrypted table");
+
+    // The rejected key ID must not be used for later writes to the table
+    sql("INSERT INTO %s VALUES (1)", unencryptedTable);
+
+    validationCatalog.initialize(catalogName, catalogConfig);
+    Table table = validationCatalog.loadTable(TableIdentifier.of("default", 
UNENCRYPTED_TABLE));
+    assertThat(table.currentSnapshot().allManifests(table.io())).hasSize(1);
+  }
+
+  @TestTemplate
+  public void testRejectedKeyIdInTransactionOnUnencryptedTable() {

Review Comment:
   This test is valuable because an implementation that guards doCommit only 
would fail this



-- 
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