title: How to pass variables to spark.sql query in pyspark?
body: <p>How to pass variables to spark.sql query in pyspark? When I query a table it fails with a <code>AnalysisException</code>. Why?</p>
  
  <pre><code>&gt;&gt;&gt; spark.sql("select * from student").show()
  
  +-------+--------+
  |roll_no|    name|
  +-------+--------+
  |      1|ravindra|
  +-------+--------+
  
  &gt;&gt;&gt; spark.sql("select * from student where roll_no={0} and name={1}".format(id,name)).show()
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/spark-2.3.0-bin-hadoop2.6/python/pyspark/sql/session.py", line 767, in sql
      return DataFrame(self._jsparkSession.sql(sqlQuery), self._wrapped)
    File "/usr/local/spark-2.3.0-bin-hadoop2.6/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__
    File "/usr/local/spark-2.3.0-bin-hadoop2.6/python/pyspark/sql/utils.py", line 69, in deco
      raise AnalysisException(s.split(': ', 1)[1], stackTrace)
  pyspark.sql.utils.AnalysisException: u"cannot resolve '`ravindra`' given input columns: [default.student.id, default.student.roll_no, default.student.name]; line 1 pos 47;\n'Project [*]\n+- 'Filter ((roll_no#21 = 0) &amp;&amp; (name#22 = 'ravindra))\n   +- SubqueryAlias `default`.`student`\n      +- HiveTableRelation `default`.`student`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [id#20, roll_no#21, name#22]\n"
  </code></pre>