dongjoon-hyun commented on a change in pull request #29812:
URL: https://github.com/apache/spark/pull/29812#discussion_r507238910
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/UpdateFields.scala
##########
@@ -17,19 +17,61 @@
package org.apache.spark.sql.catalyst.optimizer
-import org.apache.spark.sql.catalyst.expressions.UpdateFields
+import java.util.Locale
+
+import scala.collection.mutable
+
+import org.apache.spark.sql.catalyst.expressions.{Expression, UpdateFields,
WithField}
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.catalyst.rules.Rule
+import org.apache.spark.sql.internal.SQLConf
/**
- * Combines all adjacent [[UpdateFields]] expression into a single
[[UpdateFields]] expression.
+ * Optimizes [[UpdateFields]] expression chains.
*/
-object CombineUpdateFields extends Rule[LogicalPlan] {
- def apply(plan: LogicalPlan): LogicalPlan = plan transformAllExpressions {
+object OptimizeUpdateFields extends Rule[LogicalPlan] {
+ val optimizeUpdateFields: PartialFunction[Expression, Expression] = {
+ case UpdateFields(structExpr, fieldOps)
+ if fieldOps.forall(_.isInstanceOf[WithField]) &&
+
fieldOps.map(_.asInstanceOf[WithField].name.toLowerCase(Locale.ROOT)).distinct.length
!=
Review comment:
No, what I mean is that we don't need to execute line 39~69 at all.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]