This is an automated email from the ASF dual-hosted git repository.

taowang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new 28a6415d1 [AMORO-3713] fix bug of merging into when selecting less 
columns from souce table than target mixed table (#3722)
28a6415d1 is described below

commit 28a6415d1ae6f93db7add669eb68172231c833b6
Author: Nico CHen <[email protected]>
AuthorDate: Wed Aug 13 10:08:35 2025 +0800

    [AMORO-3713] fix bug of merging into when selecting less columns from souce 
table than target mixed table (#3722)
    
    [AMORO-3713]got IndexOutOfBoundsException When Using Partial Table Fields 
as MERGE Source
---
 .../analysis/RewriteMixedFormatMergeIntoTable.scala         | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/scala/org/apache/amoro/spark/sql/catalyst/analysis/RewriteMixedFormatMergeIntoTable.scala
 
b/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/scala/org/apache/amoro/spark/sql/catalyst/analysis/RewriteMixedFormatMergeIntoTable.scala
index ccaa23468..6268a0c4d 100644
--- 
a/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/scala/org/apache/amoro/spark/sql/catalyst/analysis/RewriteMixedFormatMergeIntoTable.scala
+++ 
b/amoro-format-mixed/amoro-mixed-spark/v3.3/amoro-mixed-spark-3.3/src/main/scala/org/apache/amoro/spark/sql/catalyst/analysis/RewriteMixedFormatMergeIntoTable.scala
@@ -132,10 +132,10 @@ case class RewriteMixedFormatMergeIntoTable(spark: 
SparkSession) extends Rule[Lo
         Some(ProjectingInternalRow.newProjectInternalRow(plan, targetRowAttrs, 
isFront = true, 0))
       val backRowProjection =
         ProjectingInternalRow.newProjectInternalRow(
-          source,
+          plan,
           targetRowAttrs,
           isFront = false,
-          1 + rowIdAttrs.size)
+          rowIdAttrs.size)
       (frontRowProjection, backRowProjection)
     } else {
       val frontRowProjection =
@@ -187,7 +187,8 @@ case class RewriteMixedFormatMergeIntoTable(spark: 
SparkSession) extends Rule[Lo
     // also disable broadcasts for the target table to perform the cardinality 
check
     val joinType = if (notMatchedActions.isEmpty) Inner else RightOuter
     val joinHint = JoinHint(leftHint = 
Some(HintInfo(Some(NO_BROADCAST_HASH))), rightHint = None)
-    val joinPlan = Join(targetTableProj, sourceTableProj, joinType, 
Some(cond), joinHint)
+    val joinPlan =
+      Join(NoStatsUnaryNode(targetTableProj), sourceTableProj, joinType, 
Some(cond), joinHint)
 
     val matchedConditions = matchedActions.map(actionCondition)
     val matchedOutputs =
@@ -264,14 +265,16 @@ case class RewriteMixedFormatMergeIntoTable(spark: 
SparkSession) extends Rule[Lo
 
     action match {
       case u: UpdateAction =>
-        val finalSourceOutput = rebuildAttribute(sourceOutput, u.assignments)
+//        val finalSourceOutput = rebuildAttribute(sourceOutput, u.assignments)
+        val finalSourceOutput = u.assignments.map(_.value)
         Seq(Literal(UPDATE_OPERATION)) ++ targetOutput ++ finalSourceOutput
 
       case _: DeleteAction =>
         Seq(Literal(DELETE_OPERATION)) ++ targetOutput ++ sourceOutput
 
       case i: InsertAction =>
-        val finalSourceOutput = rebuildAttribute(sourceOutput, i.assignments)
+//        val finalSourceOutput = rebuildAttribute(sourceOutput, i.assignments)
+        val finalSourceOutput = i.assignments.map(_.value)
         Seq(Literal(INSERT_OPERATION)) ++ targetOutput ++ finalSourceOutput
 
       case other =>

Reply via email to