Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val conf = new SparkConf().setAppName("Simple Application").setMaster("local")
- val sc = new SparkContext(conf)
- val spark = org.apache.spark.sql.SparkSession.builder
- .master("local")
- .appName("Spark CSV Reader")
- .getOrCreate;
- val samples = spark.read.format("com.databricks.spark.csv").
- option("sep",",").
- csv("samples.txt").
- toDF("user_id", "song_id", "date_id")
- val songs = spark.read.format("com.databricks.spark.csv").
- option("sep",",").
- csv("tracks1.txt").
- toDF("track_id","song_id","artist","title","nowe_id")
- samples.groupBy("song_id")
- .count().join(songs,"song_id")
- .select("title","artist","count")
- .orderBy(desc("count"))
- .show(10,false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement