diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala index ec258e2e46459..899adcae87ef2 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InMemoryFileIndex.scala @@ -103,7 +103,8 @@ class InMemoryFileIndex( } override def equals(other: Any): Boolean = other match { - case hdfs: InMemoryFileIndex => rootPaths.sorted == hdfs.rootPaths.sorted + case hdfs: InMemoryFileIndex if rootPaths.size == hdfs.rootPaths.size => + rootPaths.sorted == hdfs.rootPaths.sorted case _ => false }