anishshri-db commented on code in PR #47574:
URL: https://github.com/apache/spark/pull/47574#discussion_r1735290658
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/state/metadata/StateMetadataSource.scala:
##########
@@ -205,26 +207,35 @@ class StateMetadataPartitionReader(
// Need this to be accessible from IncrementalExecution for the planning
rule.
private[sql] def allOperatorStateMetadata: Array[OperatorStateMetadata] = {
- val stateDir = new Path(checkpointLocation, "state")
- val opIds = fileManager
- .list(stateDir, pathNameCanBeParsedAsLongFilter).map(f =>
pathToLong(f.getPath)).sorted
- opIds.map { opId =>
- val operatorIdPath = new Path(stateDir, opId.toString)
- // check if OperatorStateMetadataV2 path exists, if it does, read it
- // otherwise, fall back to OperatorStateMetadataV1
- val operatorStateMetadataV2Path =
OperatorStateMetadataV2.metadataDirPath(operatorIdPath)
- val operatorStateMetadataVersion = if
(fileManager.exists(operatorStateMetadataV2Path)) {
- 2
- } else {
- 1
- }
-
- OperatorStateMetadataReader.createReader(
- operatorIdPath, hadoopConf, operatorStateMetadataVersion,
batchId).read() match {
- case Some(metadata) => metadata
- case None => throw
StateDataSourceErrors.failedToReadOperatorMetadata(checkpointLocation,
- batchId)
+ try {
+ val stateDir = new Path(checkpointLocation, "state")
+ val opIds = fileManager
+ .list(stateDir, pathNameCanBeParsedAsLongFilter).map(f =>
pathToLong(f.getPath)).sorted
+ opIds.map { opId =>
+ val operatorIdPath = new Path(stateDir, opId.toString)
+ // check if OperatorStateMetadataV2 path exists, if it does, read it
+ // otherwise, fall back to OperatorStateMetadataV1
+ val operatorStateMetadataV2Path =
OperatorStateMetadataV2.metadataDirPath(operatorIdPath)
+ val operatorStateMetadataVersion = if
(fileManager.exists(operatorStateMetadataV2Path)) {
+ 2
+ } else {
+ 1
+ }
+ OperatorStateMetadataReader.createReader(
+ operatorIdPath, hadoopConf, operatorStateMetadataVersion,
batchId).read() match {
+ case Some(metadata) => metadata
+ case None => throw
StateDataSourceErrors.failedToReadOperatorMetadata(checkpointLocation,
+ batchId)
+ }
}
+ } catch {
+ // if the operator metadata is not present, catch the exception
Review Comment:
Its to avoid the exception being thrown if the path doesn't exist. I don't
think we need any changes in `IncrementalExecution` - it should handle the case
and return an empty Map to the caller as we expect ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]