Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TOREE-492] Add DataFrame displayer #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.util.Try
import org.apache.spark.SparkContext
import org.apache.spark.sql.Row
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
import jupyter.Displayer
import jupyter.Displayers
import jupyter.MIMETypes
Expand Down Expand Up @@ -64,6 +63,13 @@ object ScalaDisplayers {
}
})

Displayers.register(classOf[DataFrame], new Displayer[DataFrame] {
override def display(df: DataFrame): util.Map[String, String] = toJava {
val (text, html) = displayRows(df.head(20), Some(df.schema.fieldNames))
Map(MIMEType.PlainText -> text, MIMEType.TextHtml -> html)
}
})

Displayers.register(classOf[Array[Row]], new Displayer[Array[Row]] {
override def display(arr: Array[Row]): util.Map[String, String] = toJava {
val (text, html) = displayRows(arr)
Expand Down