title: Pyspark SaveAsTable not infering schema from SQL
body: <p>I am trying to create a table from the output of a SQL query by doing the following:</p>
  
  <pre><code>sqlContext = HiveContext(self.sc)
  j = "select a as a1, b as b1, c as c1 from x"
  df = self.sqlContext.sql(j)
  df.write.saveAsTable(target_table)
  </code></pre>
  
  <p>This saves the table with 2 columns - key and value instead of the columns a1, b1, c1. I guess this is happening because i am not defining the schema here. But the same approach used to work with the deprecated df.saveAsTable(table) where it used to infer the schema automatically.</p>
  
  <p>Have things changed with the new DataFrameWriter ?</p>