I do this query in MySQL like this:
SELECT *,@a:=@a+1 AS rn FROM PERSON,(SELECT(@a:=0)) AS A
I want to know how I can do this by spark sql when I query a DataFrame,like this type:
val strSQL=" SELECT *,@a:=@a+1 AS rn FROM PERSON,(SELECT(@a:=0)) AS A"
sqlContext.sql(strSQL)
My problem is that when I run this code ,the console tell me @a:=@a+1 is wrong, I dont knwon how to write the SQL in spark SQL type.