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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/DataFrameNaFunctions.scala
##########
@@ -395,9 +395,9 @@ final class DataFrameNaFunctions private[sql](df: 
DataFrame) {
 
   private def fillMap(values: Seq[(String, Any)]): DataFrame = {
     // Error handling
-    values.foreach { case (colName, replaceValue) =>
+    val resolved = values.map { case (colName, replaceValue) =>
       // Check column name exists
-      df.resolve(colName)
+      val resolvedColumn = df.resolve(colName)

Review comment:
       This is a good point, but we should forbid nested fields as we only 
support top-level columns here. How about
   ```
   val attrToValue = AttributeMap(values.map { case (colName, replaceValue) =>
     val attr = df.resolve(colName) match {
       case a: Attribute => a
       case _ => throw new IllegalArgumentException("Nested field is not 
supported")
     }
     attr -> replaceValue
   })
   val projections = output.map {  attr =>
     attrToValue.get(attr).map {
        case v: jl.Float => fillCol[Float](attr, v) // add an overload of 
fillCol that takes Attribute
        ...
     }.getOrElse(Column(attr))
   }
   ```
   




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