Reputation: 3181
I'm trying to union two Dstreams:
val statuses = tweets.map(status => status.getText())
val users = tweets.map(status => status.getUser())
val Dates = tweets.map(status => status.getCreatedAt())
(statuses. union(Dates)).print
But I'm getting an error that there is a mismatch in types:
Found: org.apache.spark.streaming.dstream.DStream[java.util.Date]
Required: org.apache.spark.streaming.dstream.DStream[String]
How can I do the conversion?
Upvotes: 0
Views: 406
Reputation: 520
try this
val Dates = tweets.map(status => status.getCreatedAt.toString)
or if you want specific format
val format = new SimpleDateFormat("yyyy-MM-dd")
val Dates = tweets.map(status => format.format(status.getCreatedAt))
Upvotes: 2