The method `Scan.readSchema` returns the actual schema of this data source scan.
In the current file source V2 framework, the schema is not returned correctly. The result should be `readDataSchema + partitionSchema`, while the framework returns the schema which is pushed down in `SupportsPushDownRequiredColumns.requiredSchema`.
This is normally OK. But if there are overlap columns between `dataSchema` and `partitionSchema`, the result of row-base scan will be wrong. The actual schema should be
`dataSchema - overlapSchema + partitionSchema`, which is different from from the pushed down `requiredSchema`.
This PR is to:
1. Bug fix: fix the corner case that `dataSchema` overlaps with `partitionSchema`.
2. Improvement: Prune partition column values if part of the partition columns are not required.
3. Behavior change: To make it simple, the schema of `FileTable` is `dataSchema - overlapSchema + partitionSchema`, instead of mixing data schema and partitionSchema (see `PartitioningUtils.mergeDataAndPartitionSchema`)
For example, the data schema is [a,b,c], the partition schema is [b,d],
In V1, the schema of `HadoopFsRelation` is [a, b, c, d]
in File source V2 , the schema of `FileTable` is [a, c, b, d]
Putting all the partition columns to the end of table schema is more reasonable. Also, when there is `select *` operation and there is no schema pruning, the schema of `FileTable` and `FileScan` still matches.