xuanyuanking commented on a change in pull request #25768: [SPARK-29063][SQL] 
Modify fillValue approach to support joined dataframe
URL: https://github.com/apache/spark/pull/25768#discussion_r325689461
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/DataFrameNaFunctions.scala
 ##########
 @@ -497,12 +497,10 @@ final class DataFrameNaFunctions private[sql](df: 
DataFrame) {
           throw new IllegalArgumentException(s"$targetType is not matched at 
fillValue")
       }
       // Only fill if the column is part of the cols list.
-      if (typeMatches && cols.exists(col => columnEquals(f.name, col))) {
-        fillCol[T](f, value)
-      } else {
-        df.col(f.name)
-      }
+      typeMatches && cols.exists(col => columnEquals(f.name, col))
+    }.map { col =>
+      (col.name, fillCol[T](col, value))
     }
-    df.select(projections : _*)
+    df.withColumns(fillColumnsInfo.map(_._1), fillColumnsInfo.map(_._2))
 
 Review comment:
   Yes, in the new approach, we only pass in the columns found in the existing 
fields, and `withColumns` will replace the existing columns with the original 
order.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to