I need to save the output of df.show() as a string so that i can email it directly.
For ex., the below example taken from official spark docs,:
val d
scala.Console has a withOut method for this kind of thing:
scala.Console
withOut
val outCapture = new ByteArrayOutputStream Console.withOut(outCapture) { df.show() } val result = new String(outCapture.toByteArray)