knockdata / spark-highcharts

Support Highcharts in Apache Zeppelin
Apache License 2.0
81 stars 14 forks source link

NoSuchElementException while plotting multiple lines #26

Closed asarkar closed 7 years ago

asarkar commented 7 years ago

Given:

import com.knockdata.spark.highcharts._
import com.knockdata.spark.highcharts.model._

val tbl = df.select(col("`gc.ps_scavenge.count`").as("gcCount"), col("`gc.ps_scavenge.time`").as("gcTime"),
col("heap"), col("`heap.used`").as("heapUsed"), col("mem").as("memory"), ($"mem" - $"`mem.free`").as("freeMemory"),
col("threads"), col("`threads.peak`").as("peakThreads"), col("`threads.totalStarted`").as("totalStartedThreads"))
  .withColumn("time", monotonically_increasing_id())
  .orderBy(col("time").asc)

tbl.show()

+-------+------+------+--------+------+----------+-------+-----------+-------------------+-----------+ |gcCount|gcTime| heap|heapUsed|memory|freeMemory|threads|peakThreads|totalStartedThreads| time| +-------+------+------+--------+------+----------+-------+-----------+-------------------+-----------+ | 6700| 48417|466432| 239197|482956| 347882| 67| 265| 2129| 0| | 6702| 48425|466432| 210667|483090| 319486| 67| 265| 2129| 1| | 6703| 48429|466432| 244078|483430| 353237| 67| 265| 2129| 2| | 6699| 48414|466432| 250593|482370| 359204| 66| 265| 2128| 8589934592| | 6699| 48414|466432| 256642|482398| 365281| 67| 265| 2129| 8589934593| | 6700| 48417|466432| 214023|482885| 322637| 67| 265| 2129| 8589934594| | 6716| 48518|466432| 210930|482590| 319249| 67| 265| 2129|17179869184|

highcharts(tbl
  .seriesCol("gcCount")
  .seriesCol("gcTime"))
  .plot()
tbl: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [gcCount: bigint, gcTime: bigint ... 8 more fields]
java.util.NoSuchElementException: head of empty list
  at scala.collection.immutable.Nil$.head(List.scala:422)
  at scala.collection.immutable.Nil$.head(List.scala:419)
  at com.knockdata.spark.highcharts.convert$.getCategories(convert.scala:269)
  at com.knockdata.spark.highcharts.convert$.apply(convert.scala:295)
  at com.knockdata.spark.highcharts.SeriesHolder.result(SeriesHolder.scala:187)

Zeppelin 0.7.0 with highcharts 0.6.4 built locally.

rockie-yang commented 7 years ago

It can only use one seriesCol, which means using that column's distinct value to create multiple data series. And need specify which column to use for series