Skip to content

Commit

Permalink
[SPARK-28098] Fix NPE when specifying parquet files instead of paths (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinii authored Aug 20, 2021
1 parent cefa493 commit 4375b8a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,20 @@ class InMemoryFileIndex(
new mutable.LinkedHashMap[Path, FileStatus]() ++= files.map(f => f.getPath -> f)
cachedLeafDirToChildrenFiles =
if (readPartitionWithSubdirectoryEnabled) {
files.toArray.groupBy(file => getRootPathsLeafDir(file.getPath.getParent))
files.toArray.groupBy(file => getRootPathsLeafDir(file.getPath.getParent, file.getPath))
} else {
files.toArray.groupBy(_.getPath.getParent)
}
cachedPartitionSpec = null
}

private def getRootPathsLeafDir(path: Path): Path = {
if (rootPaths.contains(path)) {
private def getRootPathsLeafDir(path: Path, child: Path): Path = {
if (rootPaths.contains(child)) {
path
} else if (rootPaths.contains(path)) {
path
} else {
getRootPathsLeafDir(path.getParent)
getRootPathsLeafDir(path.getParent, path)
}
}

Expand Down

0 comments on commit 4375b8a

Please sign in to comment.