title: How to save a table in pyspark sql?
body: <p>I want to save my resulting table into a csv, textfile or similiar to be able to perform visualization with RStudio.</p>
  
  <p>I am using pyspark.sql to perform some queries in a hadoop setup. I want to save my result in hadoop and then copy the result into my local drive.</p>
  
  <pre><code>myTable = sqlContext.sql("SOME QUERIES")
  myTable.show() # Show my result
  myTable.registerTempTable("myTable") # Save as table
  myTable.saveAsTextFile("SEARCH PATH") # Saving result in my hadoop
  </code></pre>
  
  <p>This returns this:<br>
  AttributeError: 'DataFrame' object has no attribute 'saveAsTextFile'</p>
  
  <p>This is how I usually do it when using only pyspark i.e. not pyspark.sql.</p>
  
  <p>And then I copy to local drive with</p>
  
  <pre><code>hdfs dfs –copyToLocal SEARCH PATH
  </code></pre>
  
  <p>Can anyone help me?</p>