aokolnychyi commented on code in PR #55518:
URL: https://github.com/apache/spark/pull/55518#discussion_r3786035399


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteUpdateTable.scala:
##########
@@ -41,7 +44,11 @@ object RewriteUpdateTable extends RewriteRowLevelCommand {
       EliminateSubqueryAliases(aliasedTable) match {
         case r @ ExtractV2Table(tbl: SupportsRowLevelOperations) =>
           checkNoGeneratedColumns(r, UPDATE)
-          val table = buildOperationTable(tbl, UPDATE, r.options)
+          val updatedCols = assignments.collect {

Review Comment:
   Can we add a helper like below?
   
   ```
   private def collectUpdatedAttrs(assignments: Seq[Assignment]): 
Seq[AttributeReference] = {
     assignments.collect {
       case Assignment(key: AttributeReference, value) if 
!isIdentityAssignment(key, value) => key
     }
   }
   ```
   
   And then pass AttributeReference to buildOperationTable?
   
   ```
   protected def buildOperationTable(
       table: SupportsRowLevelOperations,
       command: Command,
       options: CaseInsensitiveStringMap,
       updatedAttrs: Seq[AttributeReference] = Nil): RowLevelOperationTable = {
     val updatedColumns = updatedAttrs.map(attr => 
FieldReference(Seq(attr.name)))
     ...
   }
   ```
   
   So that RewriteUpdateTable becomes a bit easier. I also see you may use 
`collectUpdatedAttrs` in a few other places.



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