AshSr AshSr - 22 days ago 9
Scala Question

error: value write is not a member of unit

I have joined two tables using SparkSql when i try to save output in .csv format it shows me error.

query i have coded to join two tables

val mostViewedMovies=sqlContext.sql("select mostviewed.movieID,moviesTable.title,mostviewed.views from mostViewed inner join moviesTable on mostViewed.movieID=moviesTable.movieID order by mostViewed.views DESC limit 10").show


tried to save output with below command

mostViewedMovies.write.format("csv").save("/home/hadoop.....")


error

error: value write is not a member of unit


Suggest me

Answer Source

Before saving it,remove .show() from mostViewedMovies.

Try this

val mostViewedMovies=sqlContext.sql("select mostviewed.movieID,moviesTable.title,mostviewed.views from mostViewed inner join moviesTable on mostViewed.movieID=moviesTable.movieID order by mostViewed.views DESC limit 10")