cloud-fan commented on a change in pull request #31494:
URL: https://github.com/apache/spark/pull/31494#discussion_r572293623



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/AlterTableTests.scala
##########
@@ -1141,6 +1141,36 @@ trait AlterTableTests extends SharedSparkSession {
     }
   }
 
+  test("AlterTable: remove nonexistent table property") {
+    val t = s"${catalogAndNamespace}table_name"
+    withTable(t) {
+      sql(s"CREATE TABLE $t (id int) USING $v2Format TBLPROPERTIES('test' = 
'34')")
+
+      val tableName = fullTableName(t)
+      val table = getTableMetadata(tableName)
+
+      assert(table.name === tableName)
+      assert(table.properties ===
+        withDefaultOwnership(Map("provider" -> v2Format, "test" -> 
"34")).asJava)
+
+      val exc = intercept[AnalysisException] {
+        sql(s"ALTER TABLE $t UNSET TBLPROPERTIES ('unknown')")
+      }
+      assert(exc.getMessage.contains("Attempted to unset non-existent property 
'unknown'"))
+
+      // Reserved property "comment" should be allowed regardless.
+      sql(s"ALTER TABLE $t UNSET TBLPROPERTIES ('comment')")

Review comment:
       hmm, IIRC we don't even allow users to set the reserved property in 
CREATE TABLE.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to