title: How to solve the following issue in Spark 3.0? Can not create the managed table. The associated location already exists.;
body: <p>In my spark job, I tried to overwrite a table in each microbatch of structured streaming</p>
  <pre><code>batchDF.write.mode(SaveMode.Overwrite).saveAsTable(&quot;mytable&quot;)
  </code></pre>
  <p>It generated the following error.</p>
  <pre><code>  Can not create the managed table('`mytable`'). The associated location('file:/home/ec2-user/environment/spark/spark-local/spark-warehouse/mytable') already exists.;
  
  </code></pre>
  <p>I knew in Spark 2.xx, the way to solve this issue is to add the following option.</p>
  <pre><code>spark.conf.set(&quot;spark.sql.legacy.allowCreatingManagedTableUsingNonemptyLocation&quot;,&quot;true&quot;)
  </code></pre>
  <p>It works well in spark 2.xx. However, this option was removed in Spark 3.0.0. Then, how should we solve this issue in Spark 3.0.0?</p>
  <p>Thanks!</p>