[SPARK-3007][SQL]Add "Dynamic Partition" support to Spark Sql hive

the detail please refer the comment of https://issues.apache.org/jira/browse/SPARK-3007
Sorry, too many comments for a single line :)

Just realized this line is on the critical path, please forget about the assertion I mentioned above. To avoid unnecessary computations and branches, I'd suggest something like:

```scala
if (dynamicPartNum > 0) {
  iter.map {
    // With DP
  }
} else {
  iter.map {
    // Without DP
  }
}
```