Spark SQL passing a variable
You can pass a string into sql statement like below
id = "1"
query = "SELECT count from mytable WHERE id='{}'".format(id)
sqlContext.sql(query)
You are almost there just missed s
:)
sqlContext.sql(s"SELECT count from mytable WHERE id=$id")