title: AWS Gluescript using spark, how does a glue job help spark persist data to the persistent storage layer, like parquet?
body: <p>We have some gluejobs which uses Spark dataframes. We write the dataframe to a parquet file in the job like this.</p>
  <pre><code>matched.write.mode(&quot;overwrite&quot;).parquet(output)
  </code></pre>
  <p>We then set the bookmark, which I have now learned has nothing to do with persisting data, rather tracking data about the job.</p>
  <pre><code>job.commit()
  </code></pre>
  <p>Now, if I throw any exception after <strong>matched.write.mode(&quot;overwrite&quot;).parquet(output)</strong> then my data does not get persisted to a parquet file and Athena cannot read it.</p>
  <p>If I just let the script contiues, it persists the data.</p>
  <p>My question is then where and how does the gluejob actually persist the data that was written here -&gt; <strong>matched.write.mode(&quot;overwrite&quot;).parquet(output)</strong>
  To me it seems as if the data is only persisted to parquet if we allow the gluejob to finish executing normally? Is this assumption correct? This is what all of my tests confirm but I may be missing something as I used to think that matched.write does the writing and persisting already.</p>