title: Check if a table exists in Hive in pyspark sparksession
body: <p>I have the  following code. What I am trying to achieve is to check if a table already exists in a database in Hive. If yes, then append new data into. If not then create a new table.</p>
  <pre><code> if &quot;table1&quot; in sqlContext.tableNames(&quot;db1&quot;):
      df.write.format(&quot;orc&quot;).mode(&quot;append&quot;).insertInto(&quot;db1.table1&quot;)
   else:
      df.write.format(&quot;orc&quot;).saveAsTable(&quot;db1.table1&quot;)
  </code></pre>
  <p>But I am getting this error:</p>
  <pre><code>NameError: name 'sqlContext' is not defined
  </code></pre>
  <p>I am using spark session in Pyspark with Jupyter Notebook:</p>
  <pre><code>spark = SparkSession.builder.config(conf=conf).enableHiveSupport().getOrCreate()
  </code></pre>
  <p>How can I fix the error?</p>