fqaiser94 commented on a change in pull request #27066:
URL: https://github.com/apache/spark/pull/27066#discussion_r464177138



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Column.scala
##########
@@ -871,6 +871,72 @@ class Column(val expr: Expression) extends Logging {
    */
   def getItem(key: Any): Column = withExpr { UnresolvedExtractValue(expr, 
Literal(key)) }
 
+  // scalastyle:off line.size.limit
+  /**
+   * An expression that adds/replaces field in `StructType` by name.
+   *
+   * {{{
+   *   val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col")
+   *   df.select($"struct_col".withField("c", lit(3)))

Review comment:
       I failed to write a test case to cover this scenario, my bad. 
   And yea, I just tried this example again, and I can see that it fails. 
   The issue is that I `override foldable` for this `Unevaluable` Expression. 
And so, when `foldable` returns true, Spark tries to evaluate the expression 
and it fails at that point. 
   I kind-of realized this as well recently and in my PR for `dropFields` 
[here](https://github.com/apache/spark/pull/29322/files#diff-c1758d627a06084e577be0d33d47f44eL566),
 I've fixed the issue (basically i just don't `override foldable` anymore). 
   I guess I should submit a follow-up PR to fix this immediately with 
associated unit tests? 




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