Skip to content

Commit

Permalink
ready for review
Browse files Browse the repository at this point in the history
  • Loading branch information
brkyvz committed Sep 19, 2016
1 parent e063206 commit e4e8f1a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.sql.execution.datasources

import java.io.FileNotFoundException

import scala.collection.mutable

import org.apache.hadoop.fs.{FileStatus, LocatedFileStatus, Path}
Expand Down Expand Up @@ -97,8 +99,14 @@ class ListingFileCatalog(
logTrace(s"Listing $path on driver")

val childStatuses = {
val stats = fs.listStatus(path)
if (pathFilter != null) stats.filter(f => pathFilter.accept(f.getPath)) else stats
try {
val stats = fs.listStatus(path)
if (pathFilter != null) stats.filter(f => pathFilter.accept(f.getPath)) else stats
} catch {
case _: FileNotFoundException =>
logWarning(s"The directory $path was not found. Was it deleted very recently?")
Array.empty[FileStatus]
}
}

childStatuses.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@ class FileCatalogSuite extends SharedSQLContext {

}
}

test("ListingFileCatalog: folders that don't exist don't throw exceptions") {
withTempDir { dir =>
val deletedFolder = new File(dir, "deleted")
assert(!deletedFolder.exists())
val catalog1 = new ListingFileCatalog(
spark, Seq(new Path(deletedFolder.getCanonicalPath)), Map.empty, None)
// doesn't throw an exception
assert(catalog1.listLeafFiles(catalog1.paths).isEmpty)
}
}
}

0 comments on commit e4e8f1a

Please sign in to comment.