title: Can we execute an .hql file directly from pyspark?
body: <p>I could run a hive query from pyspark and also could read each line from the .hql file and run the query. But, I want to run the .hql file directly from the pyspark program. I tried searching the internet but couldnt find a solution. </p>
  
  <p>I just wanted to know whether I can run the hql file like I normally with </p>
  
  <pre><code>hive -f "hql_file.hql"
  </code></pre>
  
  <p>or spark doesnt provide such kind of solution?</p>
  
  <p>so far I could go with and this works:
  I havent added the libraries here..The following code works with retrieving each line from the hql file</p>
  
  <pre><code>sc=SparkContext(conf=conf)
  hc=HiveContext(sc)
  
  with open("hql_file_path","r+") as fr:
   for query in fr:
    result=hc.hql(query)
    print result.collect()
  </code></pre>