Skip to content
Advertisement

Spark SQL passing a variable

I have following Spark sql and I want to pass variable to it. How to do that? I tried following way.

 sqlContext.sql("SELECT count from mytable WHERE id=$id")

Advertisement

Answer

You are almost there just missed s 🙂

sqlContext.sql(s"SELECT count from mytable WHERE id=$id")
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement