aatuc210
aatuc210

Reputation: 1868

"missing parameter type" in groupBy

I'm a scala newbie that's having a hard time with what should be a simple line of code. I do a .groupBy operation and close over "it", but the compiler complains about a "missing parameter type", and I have no idea how to fix it. Here's the exact code (it's on a different network so I have to retype - excuse any typos):

val rddSAInCache: RDD[Map[String, Any]] = getCache(SAInCacheExported, rddconfig)
  .filter(it => it.path(EventType).getOrElse(NONE) == "SAInCache")
  .map(it => 
    Map(
      ("SAInCache" -> it.path(Time).getOrElse(NONE)), 
      (RequestID -> it.path(RequestID).getOrElse(NONE))
    )
  )
  .groupBy(it => it.path(RequestID.getOrElse(NONE))

The compiler is able to infer that "it" is a Map[String, Any] in both the filter and the map, but not the groupBy. Why??

Upvotes: 1

Views: 1363

Answers (1)

som-snytt
som-snytt

Reputation: 39577

More of a suggestion than an answer:

Try splitting up the chained invocation:

val foo = rdd map f
val bar = foo groupBy g

Get the type of foo in the REPL.

You're asking it to solve the result type of the map, which is a Map, together with the groupBy, which is heavily overloaded and carries implicits.

Without knowing much about the API, it wouldn't surprise me if a type param is not inferrable.

Upvotes: 2

Related Questions