You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/05/02 10:44:18 UTC
[GitHub] [spark] wankunde commented on pull request #27030: [SPARK-30244][SQL] Emit pre/post events for "Partition" methods in ExternalCatalogWithListener
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org