Apache Zeppelin 不返回聚合数据
Apache Zeppelin not returning aggregate data
我是 运行 Apache Spark 2.0.1 和 Apache Zeppelin 0.6.2。
在 Zeppelin 中,我有以下段落:
val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options(Map( "table" -> "iot_data2", "keyspace" -> "iot" ))
.load()
import org.apache.spark.sql.functions.{avg,round}
val ts = $"updated_time".cast("long")
val interval = (round(ts / 3600L) * 3600.0).cast("timestamp").alias("time")
df.groupBy($"a", $"b", $"date_bucket", interval).avg("t").createOrReplaceTempView("iot_avg")
下一段我正在尝试绘制图表,但 avg("t") 的值始终为 0:
%sql
select time,avg("t") as avg_t from ble_temp_avg where a = '${a}' and b = '${b}' group by time order by time
我想我错过了一些非常明显的东西,但我只是不知道它是什么作为新的 Spark 和 Zeppelin 用户。
这在我重写段落后似乎有效:
第一段中:
val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options(Map( "table" -> "iot_data2", "keyspace" -> "iot" ))
.load()
import org.apache.spark.sql.functions.{avg,round}
val ts = $"updated_time".cast("long")
val interval = (round(ts / 3600L) * 3600.0).cast("timestamp").alias("time")
df.select($"a", $"b", $"date_bucket", interval, $"t").createOrReplaceTempView("iot_avg")
第二段中:
%sql
select time,avg(t) as avg_t from iot_avg where a = 'test1' and b = 'test2' group by time order by time
我是 运行 Apache Spark 2.0.1 和 Apache Zeppelin 0.6.2。
在 Zeppelin 中,我有以下段落:
val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options(Map( "table" -> "iot_data2", "keyspace" -> "iot" ))
.load()
import org.apache.spark.sql.functions.{avg,round}
val ts = $"updated_time".cast("long")
val interval = (round(ts / 3600L) * 3600.0).cast("timestamp").alias("time")
df.groupBy($"a", $"b", $"date_bucket", interval).avg("t").createOrReplaceTempView("iot_avg")
下一段我正在尝试绘制图表,但 avg("t") 的值始终为 0:
%sql
select time,avg("t") as avg_t from ble_temp_avg where a = '${a}' and b = '${b}' group by time order by time
我想我错过了一些非常明显的东西,但我只是不知道它是什么作为新的 Spark 和 Zeppelin 用户。
这在我重写段落后似乎有效:
第一段中:
val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options(Map( "table" -> "iot_data2", "keyspace" -> "iot" ))
.load()
import org.apache.spark.sql.functions.{avg,round}
val ts = $"updated_time".cast("long")
val interval = (round(ts / 3600L) * 3600.0).cast("timestamp").alias("time")
df.select($"a", $"b", $"date_bucket", interval, $"t").createOrReplaceTempView("iot_avg")
第二段中:
%sql
select time,avg(t) as avg_t from iot_avg where a = 'test1' and b = 'test2' group by time order by time