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


##########
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");

Review Comment:
   Ah great catch - I assume you're referring to the error message being 
misleading here. Wonder if we could do that separately as it's unrelated to 
this PR's fix? Put up https://github.com/apache/iceberg/pull/19004 with my 
opinion of a better error message for this case



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