Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ abstract class PartitioningAwareFileIndex(

protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]]

protected lazy val pathGlobFilter = parameters.get("pathGlobFilter").map(new GlobFilter(_))
private val caseInsensitiveMap = CaseInsensitiveMap(parameters)

protected lazy val pathGlobFilter: Option[GlobFilter] =
caseInsensitiveMap.get("pathGlobFilter").map(new GlobFilter(_))

protected def matchGlobPattern(file: FileStatus): Boolean = {
pathGlobFilter.forall(_.accept(file.getPath))
}

protected lazy val recursiveFileLookup = {
parameters.getOrElse("recursiveFileLookup", "false").toBoolean
protected lazy val recursiveFileLookup: Boolean = {
caseInsensitiveMap.getOrElse("recursiveFileLookup", "false").toBoolean
}

override def listFiles(
Expand Down Expand Up @@ -215,7 +218,7 @@ abstract class PartitioningAwareFileIndex(
* and the returned DataFrame will have the column of `something`.
*/
private def basePaths: Set[Path] = {
parameters.get(BASE_PATH_PARAM).map(new Path(_)) match {
caseInsensitiveMap.get(BASE_PATH_PARAM).map(new Path(_)) match {
case Some(userDefinedBasePath) =>
val fs = userDefinedBasePath.getFileSystem(hadoopConf)
if (!fs.isDirectory(userDefinedBasePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,15 @@ class FileBasedDataSourceSuite extends QueryTest

assert(fileList.toSet === expectedFileList.toSet)

val fileList2 = spark.read.format("binaryFile")
.option("recursiveFileLookup", true)
.option("pathGlobFilter", "*.bin")
.load(dataPath)
.select("path").collect().map(_.getString(0))

assert(fileList2.toSet === expectedFileList.filter(_.endsWith(".bin")).toSet)
withClue("SPARK-32368: 'recursiveFileLookup' and 'pathGlobFilter' can be case insensitive") {
val fileList2 = spark.read.format("binaryFile")
.option("RecuRsivefileLookup", true)
.option("PaThglobFilter", "*.bin")
.load(dataPath)
.select("path").collect().map(_.getString(0))

assert(fileList2.toSet === expectedFileList.filter(_.endsWith(".bin")).toSet)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,15 @@ class FileIndexSuite extends SharedSparkSession {
val wrongBasePath = new File(dir, "unknown")
// basePath must be a directory
wrongBasePath.mkdir()
val parameters = Map("basePath" -> wrongBasePath.getCanonicalPath)
val fileIndex = new InMemoryFileIndex(spark, Seq(path), parameters, None)
val msg = intercept[IllegalArgumentException] {
// trigger inferPartitioning()
fileIndex.partitionSpec()
}.getMessage
assert(msg === s"Wrong basePath ${wrongBasePath.getCanonicalPath} for the root path: $path")
withClue("SPARK-32368: 'basePath' can be case insensitive") {
val parameters = Map("bAsepAtH" -> wrongBasePath.getCanonicalPath)
val fileIndex = new InMemoryFileIndex(spark, Seq(path), parameters, None)
val msg = intercept[IllegalArgumentException] {
// trigger inferPartitioning()
fileIndex.partitionSpec()
}.getMessage
assert(msg === s"Wrong basePath ${wrongBasePath.getCanonicalPath} for the root path: $path")
}
}
}

Expand Down