在斯卡拉星火星火SQL平均非零值
val df = sc.parallelize(0 to 3).toDF("x")
df.registerTempTable("df")
sqlContext.sql("select * from df").show
+---+
| x|
+---+
| 0|
| 1|
| 2|
| 3|
+---+
,並想只平均非零值。試過這個(不起作用),
sqlContext.sql("select avg(nullif(x,0)) from df").show
什麼是簡單和有效的方法來平均非零值?
我猜NULLIF不星火SQL 支持 「org.apache.spark.sql.AnalysisException:未定義功能NULLIF;」 – RoyaumeIX
嘗試檢查此線程:http://stackoverflow.com/questions/32357164/sparksql-how-to-deal-with-null-values-in-user-defined-function – RoyaumeIX