Unable to create a simple RDD

#1

Hello - I am trying to create a simple RDD by executing the below command and am getting an error.

seasonsrdd = sc.parallelize([“autumn”, “winter”, “spring”, “summer”])

The error is illegal start of an expression. Does anyone know why I am getting an error?

I initiated spark context and added it at scala prompt.

Thanks.
Purnima

0 Likes

#2

Hi

Try with circular brackets
seasonsrdd = sc.parallelize((“autumn”, “winter”, “spring”, “summer”))

Regards
Senthil

0 Likes

#3

Try using below code for creating RDD
scala> val seasonsrdd = spark.sparkContext.parallelize(Array(“autumn”, “winter”, “spring”, “summer”))
seasonsrdd: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[2] at parallelize at :23

0 Likes