itskals commented on a change in pull request #25840: [SPARK-29166][SQL] Add 
parameters to limit the number of dynamic partitions for data source table
URL: https://github.com/apache/spark/pull/25840#discussion_r326471315
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/SQLHadoopMapReduceCommitProtocol.scala
 ##########
 @@ -63,7 +70,29 @@ class SQLHadoopMapReduceCommitProtocol(
         committer = ctor.newInstance()
       }
     }
+    totalPartitions = new AtomicInteger(0)
     logInfo(s"Using output committer class 
${committer.getClass.getCanonicalName}")
     committer
   }
+
+  override def newTaskTempFile(
+      taskContext: TaskAttemptContext, dir: Option[String], ext: String): 
String = {
+    val path = super.newTaskTempFile(taskContext, dir, ext)
+    totalPartitions.incrementAndGet()
+    if (dynamicPartitionOverwrite) {
+      if (totalPartitions.get > maxDynamicPartitions) {
 
 Review comment:
   If my understanding on SQLConf.DYNAMIC_PARTITION_MAX_PARTITIONS is correct, 
that it is the max number of partitions a data source can have at any given 
time, then I am not convinced that this is the right place to check the total 
number of partitions in the data source. The best would have been 
[here](https://github.com/apache/spark/blob/76ebf2241a3f2149de13d6c89adcb86325b06004/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelationCommand.scala#L137)
 
   But it might be too late by the time control reaches there.
   One way is we can pass the initial partitions in the data source at the 
beginning, and here can check if the combined number is more than the 
configured value. But I am not sure if this is the safest way (can another 
insert happen in parallel on the data source and commit, this affecting the 
value known here.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to