Skip to content

Commit

Permalink
Add helper for users to add DataFrame#render syntax
Browse files Browse the repository at this point in the history
And more Toree API compatibility too
  • Loading branch information
alexarchambault committed Jun 21, 2023
1 parent f70e9cf commit bb5f538
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions modules/almond-spark/src/main/scala/almond/spark/syntax.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package almond.spark

import almond.display.Html
import org.apache.spark.sql._
import org.apache.spark.{SparkConf, SparkContext}

object syntax {
implicit class KernelToreeSparkOps(private val kernel: almond.api.JupyterApi) {
def sparkContext: SparkContext = sparkSession.sparkContext
def sparkConf: SparkConf = sparkContext.getConf
def sparkSession: SparkSession = SparkSession.builder().getOrCreate()
}
implicit class AlmondNetflixDataFrameOps(private val df: DataFrame) {
def render(limit: Int = 10): Html =
Html(DataFrameRenderer.render(df, limit = limit))
}
}

0 comments on commit bb5f538

Please sign in to comment.