WeichenXu123 commented on a change in pull request #27522: [WIP][SPARK-30762] 
Add dtype=float32 support to vector_to_array UDF
URL: https://github.com/apache/spark/pull/27522#discussion_r377005413
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/functions.scala
 ##########
 @@ -39,10 +39,31 @@ object functions {
     }
   }.asNonNullable()
 
+  private val vectorToArrayFloatUdf = udf { vec: Any =>
+    vec match {
+      case v: Vector => v.toArray.map(_.toFloat)
+      case v: OldVector => v.toArray.map(_.toFloat)
 
 Review comment:
   Why not merge this method into `vectorToArrayUdf` ? like:
   `vectorToArrayUdf = udf { (vec: Any, type: String) => ... }`

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