You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "YannByron (via GitHub)" <gi...@apache.org> on 2023/11/22 08:31:31 UTC

Re: [PR] [spark] Merge into support update nested column [incubator-paimon]

YannByron commented on code in PR #2365:
URL: https://github.com/apache/incubator-paimon/pull/2365#discussion_r1401676633


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/spark/sql/catalyst/analysis/AssignmentAlignmentHelper.scala:
##########
@@ -35,24 +36,32 @@ trait AssignmentAlignmentHelper extends SQLConfHelper {
   private case class AttrUpdate(ref: Seq[String], expr: Expression)
 
   /**
-   * Align update assignments to the given attrs, only supports PrimitiveType and StructType. For
-   * example, if attrs are [a int, b int, s struct(c1 int, c2 int)] and update assignments are [a =
-   * 1, s.c1 = 2], will return [1, b, struct(2, c2)].
+   * Generate aligned expressions, only supports PrimitiveType and StructType. For example, if attrs
+   * are [a int, b int, s struct(c1 int, c2 int)] and update assignments are [a = 1, s.c1 = 2], will
+   * return [1, b, struct(2, c2)].
    * @param attrs
    *   target attrs
    * @param assignments
    *   update assignments
    * @return
-   *   aligned update expressions
+   *   aligned expressions
    */
-  protected def alignUpdateAssignments(
+  protected def generateAlignedExpressions(
       attrs: Seq[Attribute],
       assignments: Seq[Assignment]): Seq[Expression] = {
     val attrUpdates = assignments.map(a => AttrUpdate(toRefSeq(a.key), a.value))
     recursiveAlignUpdates(attrs, attrUpdates)
   }
 
-  def toRefSeq(expr: Expression): Seq[String] = expr match {
+  protected def alignAssignments(
+      attrs: Seq[Attribute],
+      assignments: Seq[Assignment]): Seq[Assignment] = {
+    generateAlignedExpressions(attrs, assignments).zip(attrs).map {
+      case (expression, field) => Assignment(field, expression)
+    }
+  }
+
+  private def toRefSeq(expr: Expression): Seq[String] = expr match {

Review Comment:
   can we move this method to `ExpressionHelper`~



-- 
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: issues-unsubscribe@paimon.apache.org

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