cloud-fan commented on code in PR #52866:
URL: https://github.com/apache/spark/pull/52866#discussion_r2511308188


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/v2Commands.scala:
##########
@@ -892,11 +892,40 @@ case class MergeIntoTable(
     case _ => false
   }
 
+  private lazy val sourceSchemaForEvolution: StructType =
+    MergeIntoTable.sourceSchemaForSchemaEvolution(this)
+
+  lazy val schemaChangesNonEmpty: Boolean =
+    MergeIntoTable.schemaChanges(targetTable.schema, 
sourceSchemaForEvolution).nonEmpty
+
   lazy val needSchemaEvolution: Boolean =
     schemaEvolutionEnabled &&
-      MergeIntoTable.schemaChanges(targetTable.schema, 
sourceTable.schema).nonEmpty
+      canEvaluateSchemaEvolution &&
+      schemaChangesNonEmpty

Review Comment:
   do we really need this condition? If there is no schema change, then the 
rule `ResolveMergeIntoSchemaEvolution` returns the original merge command. If 
we need to do schema change, we calculate it twice with the current code.



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