Spark Type Unresolved issue

Hi All,

While working on the election assignment I got the below error . Can anyone please help me to figure out what’s wrong with the syntax .

scala> val electionupmap = electionup.map(rec => { val r = rec.split("\t")((r(0),r(1)),(r(6),r(10).toInt))})
:33: error: recursive value r needs type
val electionupmap = electionup.map(rec => { val r = rec.split("\t")((r(0),r(1)),(r(6),r(10).toInt))})
^
Thanks for your help :slight_smile:

Hi Sudeep,
This should work
val electionupmap = electionup.map(rec => { val r = rec.split("\t")
((r(0),r(1)),(r(6),r(10).toInt))
//The above line is the return for your electionupmap. In scala last line is for return, so do not include that return statement in the same line where r is defined, as Scala thinks that you are trying to assign something to r.
})

Thanks Ashok it worked for me :slight_smile:

1 Like