Please refer to the below example that would guide you in performing Inner join in Spark SQL.


Input Datasets:

fl:
kamini,mishra

fl1:
bbsr,india


Code:
case class emp(name:String,Lastname:String)
case class emp_detail(city:String,country:String)

val empRDD = sc.textFile("file:///home/edureka/Desktop//fl").map(_.split(",")).map(x=>emp(x(0),x(1))).toDF
val empDataRDD = sc.textFile("file:///home/edureka/Desktop/fl1").map(_.split(",")).map(x=>emp_detail(x(0),x(1))).toDF

 
empRDD.registerTempTable("emp")
empDataRDD.registerTempTable("emp_detail")

val a=   sqlContext.sql("select * from emp")
a.show()

val join=  sqlContext.sql("SELECT * FROM emp INNER JOIN emp_detail")
join.show()

ScreenShot: