划分两个DF计数但火花得0

时间:2017-01-20 12:35:39

标签: scala apache-spark

我试图划分两个DF计数但得到0我认为我需要进行类型转换。你能帮帮我吗?

val subscribed = dataDF.where("Y='yes'").count
subscribed: Long = 5289
val Total = dataDF.count
Total: Long = 45211
val success = subscribed / Total
success: Long = 0 

1 个答案:

答案 0 :(得分:1)

您必须至少将其中一个变量转换为Double

val success = subscribed.toDouble / Total
//success: Double = 0.11698480458295547