cloud-fan commented on a change in pull request #29522:
URL: https://github.com/apache/spark/pull/29522#discussion_r476186399



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ComplexTypes.scala
##########
@@ -47,7 +47,8 @@ object SimplifyExtractValueOps extends Rule[LogicalPlan] {
           // For example, if a user submits a query like this:
           // `$"struct_col".withField("b", lit(1)).withField("b", 
lit(2)).getField("b")`
           // we want to return `lit(2)` (and not `lit(1)`).
-          matches.last._2
+          val expr = matches.last._2
+          If(IsNull(struct), Literal(null, expr.dataType), expr)

Review comment:
       other optimizer rules will optimize it, but yea it's better to not 
introduce unnecessary plan change.




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

Reply via email to