title: ReplaceWhere greater than year partition in delta table
body: <p>This is how my data is stored in 'year' partition in a delta table
  <a href="https://i.stack.imgur.com/jcldD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jcldD.png" alt="enter image description here" /></a></p>
  <p>This is the query I want to write. df_data_model only has data for years 2020 and above. After executing this query I only want year greater than 2020 to be present in delta table and rest deleted. Can this be achived with a query like this ? If yes what should I write in <code>&lt;?&gt;</code> . If not what additional script do I need to write if I am to automate this.</p>
  <p>The <strong>gist</strong> of the question is &quot;Delete data that do not exist in DF, replace data that exists and create new folders for new data&quot;</p>
  <pre><code>(df_data_model
   .write
   .partitionBy(&quot;Year&quot;)
   .mode('overwrite') 
   .option(&quot;replaceWhere&quot;, &quot;&lt;?&gt;&quot;)
   .format('delta')
   .save(path_delta)
    )
  </code></pre>