dongjoon-hyun commented on code in PR #59918:
URL: https://github.com/apache/spark/pull/59918#discussion_r4415832341


##########
sql/core/src/test/scala/org/apache/spark/sql/connector/UpdateTableSuiteBase.scala:
##########
@@ -915,6 +915,30 @@ abstract class UpdateTableSuiteBase extends 
RowLevelOperationSuiteBase {
     checkUpdateMetrics(numUpdatedRows = 2, numCopiedRows = 0)
   }
 
+  test("SPARK-60708: update char/varchar table with metadata columns") {
+    createTable("pk INT NOT NULL, id INT, dep STRING, name VARCHAR(10)")
+
+    append("pk INT NOT NULL, id INT, dep STRING, name STRING",
+      """{ "pk": 1, "id": 1, "dep": "hr", "name": "a" }
+        |{ "pk": 2, "id": 2, "dep": "software", "name": "b" }
+        |{ "pk": 3, "id": 3, "dep": "hr", "name": "c" }
+        |""".stripMargin)
+
+    sql(s"UPDATE $tableNameAsString SET id = -1 WHERE id IN (1, 2) AND 
_partition = 'hr'")
+
+    checkAnswer(
+      sql(s"SELECT * FROM $tableNameAsString"),
+      Row(1, -1, "hr", "a") :: Row(2, 2, "software", "b") :: Row(3, 3, "hr", 
"c") :: Nil)
+    checkUpdateMetrics(numUpdatedRows = 1, numCopiedRows = 1)
+
+    sql(s"UPDATE $tableNameAsString t SET t.id = t.index + 10 WHERE t.pk = 2")
+
+    checkAnswer(
+      sql(s"SELECT * FROM $tableNameAsString"),
+      Row(1, -1, "hr", "a") :: Row(2, 10, "software", "b") :: Row(3, 3, "hr", 
"c") :: Nil)
+    checkUpdateMetrics(numUpdatedRows = 1, numCopiedRows = 0)
+  }

Review Comment:
   Thank you, @peter-toth. I added your test as is in 00136697f1a.
   
   I got the same results: it fails in all five UPDATE suites with your 
`transformExpressions` variant and without this fix, and it passes with this 
PR. The variant fails only at execution (`INTERNAL_ERROR_ATTRIBUTE_NOT_FOUND`), 
because it remaps the outer attributes of `Exists` but not the `OuterReference` 
inside the subquery, so the analyzer does not catch it.
   
   There is no `MERGE` counterpart. `MERGE` conditions cannot have subqueries 
(`UNSUPPORTED_MERGE_CONDITION.SUBQUERY`), and a correlated scalar subquery in 
`MERGE` assignments fails with `UNSUPPORTED_CORRELATED_SCALAR_SUBQUERY` even 
without `CHAR`/`VARCHAR` columns.
   



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