title: getting error while trying to read athena table in spark
body: <p>I have the following code snippet in pyspark:</p>
  <pre><code>import pandas as pd
  from pyspark import SparkContext, SparkConf
  from pyspark.context import SparkContext
  from pyspark.sql import Row, SQLContext, SparkSession
  import pyspark.sql.dataframe
  
  def validate_data():
      conf = SparkConf().setAppName(&quot;app&quot;)
      spark = SparkContext(conf=conf)
      config = {
      &quot;val_path&quot; : &quot;s3://forecasting/data/validation.csv&quot;
      }
  
      data1_df = spark.read.table(&quot;db1.data_dest”)
      data2_df = spark.read.table(&quot;db2.data_source”)
      print(data1_df.count())
      print(data2_df.count())
  
  
  if __name__ == &quot;__main__&quot;:
      validate_data()
  </code></pre>
  <p><em>Now this code works fine when run on jupyter notebook on sagemaker ( connecting to EMR )</em></p>
  <p>but when we are running as a python script on terminal, its throwing this error</p>
  <p><strong>Error message</strong></p>
  <pre><code>AttributeError: 'SparkContext' object has no attribute 'read'
  </code></pre>
  <p>We have to automate these notebooks, so we are trying to convert them to python scripts</p>