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 @@ -101,7 +101,7 @@ class InMemoryFileIndex(
}

override def equals(other: Any): Boolean = other match {
case hdfs: InMemoryFileIndex => rootPaths.toSet == hdfs.rootPaths.toSet
case hdfs: InMemoryFileIndex => rootPaths.sorted == hdfs.rootPaths.sorted
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,30 @@ class FileIndexSuite extends SharedSparkSession {
assert(FileIndexOptions.isValidOption("modifiedafter"))
assert(FileIndexOptions.isValidOption("pathglobfilter"))
}

test("SPARK-52339: Correctly compare root paths") {
withTempDir { dir =>
val file1 = new File(dir, "text1.txt")
stringToFile(file1, "text1")
val file2 = new File(dir, "text2.txt")
stringToFile(file2, "text2")
val path1 = new Path(file1.getCanonicalPath)
val path2 = new Path(file2.getCanonicalPath)

val schema = StructType(Seq(StructField("a", StringType, false)))

// Verify that the order of paths doesn't matter
val fileIndex1a = new InMemoryFileIndex(spark, Seq(path1, path2), Map.empty, Some(schema))
val fileIndex1b = new InMemoryFileIndex(spark, Seq(path2, path1), Map.empty, Some(schema))
assert(fileIndex1a == fileIndex1b)

// Verify that a different number of paths does matter
val fileIndex2a = new InMemoryFileIndex(spark, Seq(path1, path1), Map.empty, Some(schema))
val fileIndex2b = new InMemoryFileIndex(spark, Seq(path1, path1, path1),
Map.empty, Some(schema))
assert(fileIndex2a != fileIndex2b)
}
}
}

object DeletionRaceFileSystem {
Expand Down