title: pyspark: Insert overwrite into a partitioned Table but the whole table is overwrite
body: <p>I am new in Hive and spark, trying to overwrite a partitioned table accounting to its partition column, this is the code:</p>
  <pre><code>df.createOrReplaceGlobalTempView(tempTable)
  insertSql = &quot;INSERT OVERWRITE TABLE {} PARTITION(dt) SELECT column1, column2, dt FROM {}&quot;.format(exportTable, tempTable)
  spark.sql(insertSql)
  </code></pre>
  <p>the origin exportTable:</p>
  <pre><code>column1 column2 dt
  x1      x2      20210914
  x3      x4      20210914
  x5      x6      20210914
  y1      y2      20210915
  y3      y4      20210915
  </code></pre>
  <p>tempTable:</p>
  <pre><code>column1 column2 dt
  x7      x8      20210914
  x9      x10     20210914
  </code></pre>
  <p>expected exportTable:</p>
  <pre><code>column1 column2 dt
  x7      x8      20210914
  x9      x10     20210914
  y1      y2      20210915
  y3      y4      20210915
  </code></pre>
  <p>but the exportTable like this, totally overwrite by the tempTable.:</p>
  <pre><code>column1 column2 dt
  x7      x8      20210914
  x9      x10     20210914
  </code></pre>
  <p>my spark version is 2.2 and I have to use this version...</p>
  <p>why this sql cann't work? Is there any problems?</p>