Here is a csv file contains two columns of the same type:
If we define the schema with correct types but wrong column names (reversed order):
Spark reads the csv file without any errors:
and outputs wrong result:
The correct behavior would be either output error or read columns according its names in the schema.