Search code examples
scalaapache-sparkrddapache-zeppelinprintln

Zeppelin Spark println with RDD foreach does not shown on notebook


I use Zeppelin with Spark (Scala)

val sparkLicTextFilePath = "/home/tt/Software/spark-2.3.2-bin-hadoop2.7/LICENSE"

val licLines = sc.textFile(sparkLicTextFilePath)

licLines.foreach(line=>println(line))

However, nothing is print in the notebook so far. I did try with .collect() to see if the RDD is empty or not. The RDD is ok and load file correctly.

Here is Zeppelin notebook screenshot

zeppelin_println

And some info about version of Zeppelin and spark

zeppelin 0.8.0

Zeppelin 0.8.0

Spark 2.3.2

Spark 2.3.2


Solution

  • Try to print few lines of the licLines and not all. Its probably that zeppelin is unable to print whole file.

    Try:

    val fewLicLines = licLines.take(5)
    fewLicLines.foreach(line=>println(line))