How to set Map values in spark/scala -
i new spark-scala development. trying create map values in spark using scala getting nothing printed
def createmap() : map[string, int] = { var tmap:map[string, int] = map() val tdf = spark.sql("select a, b, c temp") (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("hellllooooooooo1") ((k,v) <- tmap) println("key = " + k+ ", value= " + v) ////------this prints nothing println("hellllooooooooo2") return tmap } please suggest.
user8598832 gives how (for value of properly). reason approach doesn't work you're adding (k, v) map in executor, println occurs in driver, won't see map(s) in executor(s) (to extent might, that's artifact of running in local mode not in distributed mode).
Comments
Post a Comment