I have case where i have to combine a String with a RDD out(String)
String 1
date=
String 2 (RDD of String)
20140101
20140102
20140103
....
Output as
date=20140101, date=20140102, date=20140103,.....
Please help me to achieve this result
In Spark you would do that like this:
// Some sample data in an RDD
val data = List("20140101", "20140102", "20140103")
val rdd = sc.parallelize(data)
val concatenated = rdd.map(elem => s"date=$elem").reduce(_ + ", " + _)
Be aware thatreduce is an action. Therefore the result of reduce needs to fit in the memory of the driver.
val concatenated = rdd.map(elem => s"date=$elem").reduce(_ + ", " + _)string2.map(d => s"$string1=$d").mkString(",")