1

This is my code .

val ss  =  SparkSession.builder()
                       .appName("broadcastvariable")
                       .master("local")
                       .getOrCreate()

val sq  =  ss.sparkContext.parallelize(Seq("UK","UN","US","IN"))

val mp  =  Map("UK"->"United Kingdom","US"->"United State","IN"-> "India")

val br  =  ss.sparkContext.broadcast(mp)

val newVal  =  sq.map(f=>br.value.get(f))

newVal.foreach(f=> println(f))

and I am getting below output.

Some(United Kingdom)
None
Some(United State)
Some(India)

Why am I getting Some(United Kingdom) instead of just United Kingdom and how do I get only United kingdom instead of Some(United kingdom).

philantrovert
  • 9,904
  • 3
  • 37
  • 61
Mr. D
  • 11
  • 4

0 Answers0