Apache Spark with Scala Merge streaming text

I want to merge streaming data

val contents = tweets.map(status => status.getText())
val tSender = tweets.map(status => status.getUser().getScreenName())
tSender.print() 
contents.print()

This codes working but I need to tSender + contents format. I tried

println(tSender + contents) 

but it doesn't work. If anyone know about sth that can help me?

Upvotes: 0

Views: 45

Answers (1)

Alper t. Turker
Alper t. Turker

Reputation: 35249

Just extract all the fields you want together:

tweets.map(status => 
  s"${ status.getUser().getScreenName()} ${status.getText()}"
).print

Upvotes: 1

Related Questions