Overwriting a table that is also being read from is not supported in Spark. See one of the Spark test cases for example (Spark v3.4.4). However, it is possible to do it with INSERT OVERWRITE when overwriting partitions dynamically (SPARK-30112).
INSERT OVERWRITE