viirya commented on a change in pull request #29522:
URL: https://github.com/apache/spark/pull/29522#discussion_r476183168



##########
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:
       I think we need this only if `struct.nullable` is true?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to