Trying to read a non-existent file should always fail, but this is not what happens when you pass a schema.
import org.apache.spark.sql.catalyst.ScalaReflection
case class Person(name: String, surname: String)
val source = "/this/file/does/not/exist"
val options = Map("rowTag" -> "people")
val schema = ScalaReflection.schemaFor[Person].dataType.asInstanceOf[StructType]
// this line below fails, which is the expected behavior:
spark.read.format("xml").options(options).load(source)
// this line below succeeds, even though the source file does not exist, which is not expected:
spark.read.format("xml").schema(schema).options(options).load(source)
Trying to read a non-existent file should always fail, but this is not what happens when you pass a schema.