Print RDD content in Spark

Requirement

In this post, we are going to create an RDD and then will read the content in Spark.

Solution

 //Create RDD:
val dummyRDD = sc.parallelize(Seq(
                                ("1001", "Ename1", "Designation1", "Manager1")
                                ,("1003", "Ename2", "Designation2", "Manager2")
                                , ("1001", "Ename3", "Designation3", "Manager3")
                              ))

//Read RDD
dummyRDD.collect().foreach(println(_))
 //Read specific Column:
dummyRDD.collect().foreach(data => println(data._1, data._3))

Wrapping Up

In this post, we have learned how to read the content of the RDD.

Sharing is caring!

Subscribe to our newsletter
Loading

Leave a Reply