xianyinxin commented on a change in pull request #25626: [SPARK-28892][SQL] Add 
UPDATE support for DataSource V2
URL: https://github.com/apache/spark/pull/25626#discussion_r320608218
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
 ##########
 @@ -245,6 +246,56 @@ object DataSourceV2Strategy extends Strategy with 
PredicateHelper {
       }.toArray
       DeleteFromTableExec(r.table.asDeletable, filters) :: Nil
 
+    case UpdateTable(maybeRelation, attrs, values, condition) =>
+      val nested = 
attrs.asInstanceOf[Seq[Any]].filterNot(_.isInstanceOf[AttributeReference])
+      if (nested.nonEmpty) {
+        throw new AnalysisException(s"Update only support non-nested fields. 
Nested: $nested")
+      }
+
+      val (relation, attrsNames, newValues, newCond) = maybeRelation match {
+        case d: DataSourceV2Relation =>
+          (d, attrs.map(_.name), values, condition)
+        case Project(aliasList: Seq[Alias], r: DataSourceV2Relation) =>
 
 Review comment:
   > Let's only keep table alias. We can change the parser, replace 
`tableAlias` with `(AS? strictIdentifier)?`.
   
   Emm, they are two opts: 1. replace `tableAlias` with `(AS? 
strictIdentifier)?`; 2. keep `tableAlias` and throw `ParseException` when we 
checked it contains columns alias. The 1st opt will just throw a ParseException 
with meaningless hint, but the later we can define the error msg "`Columns 
aliases is not allowed in UPDATE.`". I think the latter is better?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to