Hello,
I am new to spark-scala development. I am trying to create map values in
spark using scala but getting nothing printed
def createMap() : Map[String, Int] = {var tMap:Map[String, Int] =
Map()val tDF = spark.sql("select a, b, c from temp")for (x <- tDF) {
val k = x.getAs[Long](0) + "|" + x.getAs[Long](1)
val v = x.getAs[Int](2)
tMap += ( k -> v )
println( k -> v ) ///--This print values}
println("Heo1")for ((k,v) <- tMap) println("key = " + k+
", value= " + v) --This prints nothing
println("Heo2")return tMap}
Please suggest.
I have posted the same at:
https://stackoverflow.com/questions/46181071/how-to-set-map-values-in-spark-scala
Thank you,
Paras