Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala case class ignoring import in the Spark shell

I hope there is an obvious answer to this question!

I've just upgraded to Spark v2.0 and have an odd problem with the spark-shell (Scala 2.11 build).

If I enter the following minimal Scala,

import java.sql.Timestamp

case class Crime(caseNumber: String, date: Timestamp, description: String, detail: String, arrest: Boolean)

I get the following error,

<console>:11: error: not found: type Timestamp

If I use the Java Timestamp class elsewhere, e.g. in a function, then no errors are generated (as you would expect because of the import).

If I fully qualify and use java.sql.Timestamp in the case class it works!

Am I missing something obvious?

like image 622
Max van Daalen Avatar asked Aug 02 '16 16:08

Max van Daalen


1 Answers

It's just that the Timestamp is not loaded in the case class declaration, to fix this you can:

:paste
import java.sql.Timestamp
case class Crime(caseNumber: String, date: Timestamp, description: String, detail: String, arrest: Boolean)

or

case class Crime(caseNumber: String, date: java.sql.Timestamp, description: String, detail: String, arrest: Boolean)
like image 165
Mikel San Vicente Avatar answered Sep 20 '22 10:09

Mikel San Vicente