scala> //for loop Example scala> val rdd = sc.parallelize(for { | x <- 1 to 3 | y <- 1 to 2 | } yield (x, None)) rdd: org.apache.spark.rdd.RDD[(Int, None.type)] = ParallelCollectionRDD[38] at parallelize at:21 scala> scala> rdd.collect() res15: Array[(Int, None.type)] = Array((1,None), (1,None), (2,None), (2,None), (3,None), (3,None))