wankunde commented on pull request #27030:
URL: https://github.com/apache/spark/pull/27030#issuecomment-622933702


   @ayudovin @dongjoon-hyun @HyukjinKwon 
   Can you emit `LoadPartitionEvent` and `LoadDynamicPartitionsEvent` ? 
   Now the user does not know which partitions are loaded, if 
`LoadDynamicPartitionsEvent` events are emitted to the listener, the user will 
know the changed partitions and add a custom callback function.
   
   ```
     def calculateDynamicPartitions(
         loadPath: Path,
         partitionSpec: TablePartitionSpec,
         numDP: Int): Array[TablePartitionSpec] = {
       assert(numDP > 0)
       try {
         val fs = loadPath.getFileSystem(new Configuration())
         fs.listStatus(loadPath).flatMap { fileStatus =>
           val dirName = fileStatus.getPath.getName
           if (dirName.contains("=")) {
             val Array(partitionColumn, partitionValue) = dirName.split("=")
             val newPartitionSpec = partitionSpec + (partitionColumn -> 
partitionValue)
             if (numDP == 1) {
               Array[TablePartitionSpec](newPartitionSpec)
             } else {
               calculateDynamicPartitions(fileStatus.getPath, newPartitionSpec, 
numDP - 1)
             }
           } else {
             Array[TablePartitionSpec]()
           }
         }
       } catch {
         case ex: Exception => Array[TablePartitionSpec]()
       }
     }    }
   ```


----------------------------------------------------------------
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]



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

Reply via email to