title: CSV file creation Error in spark_expect_jobj_class
body: <p>I want to create CSV file. While running following Spark R code it gives an error.</p>
  
  <pre><code>sc &lt;- spark_connect(master = "local", config = conf, version = '2.2.0')
  sample_tbl &lt;- spark_read_json(sc,name="example",path="example.json", header = TRUE, memory = FALSE,
                                overwrite = TRUE) 
  sdf_schema_viewer(sample_tbl) # to create db schema
  df &lt;- spark_dataframe(sample_tbl)
  spark_write_table(df, path = "data.csv", header = TRUE, delimiter = ",",
                  charset = "UTF-8", null_value = NULL,
                  options = list(), mode = NULL, partition_by = NULL)
  </code></pre>
  
  <p>Last line gives following <strong>Error</strong>,</p>
  
  <pre class="lang-none prettyprint-override"><code>Error in spark_expect_jobj_class(x, "org.apache.spark.sql.DataFrame") : 
    This operation is only supported on org.apache.spark.sql.DataFrame jobjs but found org.apache.spark.sql.Dataset instead.
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How to resolve this error in R?</p>