Davis-Zhang-Onehouse commented on code in PR #12587:
URL: https://github.com/apache/hudi/pull/12587#discussion_r1914212770


##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/dml/TestUpdateTable.scala:
##########
@@ -364,4 +365,63 @@ class TestUpdateTable extends HoodieSparkSqlTestBase {
       }
     }
   }
+
+  test("Test Update Table With Primary Key and Partition Key Updates error 
out") {
+    withRecordType()(withTempDir { tmp =>
+      Seq("cow", "mor").foreach { tableType =>
+        val tableName = generateTableName
+        // create table with primary key and partition
+        spark.sql(
+          s"""
+             |create table $tableName (
+             |  id int,
+             |  name string,
+             |  price double,
+             |  ts long,
+             |  pt string
+             |) using hudi
+             | location '${tmp.getCanonicalPath}/$tableName'
+             | tblproperties (
+             |  type = '$tableType',
+             |  primaryKey = 'id',
+             |  preCombineField = 'ts'
+             | )
+             | partitioned by (pt)
+       """.stripMargin)
+
+        // Insert initial data
+        spark.sql(s"insert into $tableName values (1, 'a1', 10.0, 1000, 
'2021')")
+
+        // Verify initial state
+        checkAnswer(s"select id, name, price, ts, pt from $tableName")(
+          Seq(1, "a1", 10.0, 1000, "2021")
+        )
+
+        // Try to update primary key (should fail)
+        val e1 = intercept[AnalysisException] {
+          spark.sql(s"update $tableName set id = 2 where id = 1")
+        }
+        assert(e1.getMessage.contains(s"Detected disallowed assignment clause 
in UPDATE statement for record key field `id`" +
+          s" for table `spark_catalog.default.$tableName`. Please remove the 
assignment clause to avoid the error."))

Review Comment:
   Also for other loggings and user messages of SQL, we are consistently 
sticking to this format. The `spark_catalog.` is the catalog name.



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

Reply via email to