You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Gengliang Wang (JIRA)" <ji...@apache.org> on 2019/04/03 15:42:00 UTC

[jira] [Created] (SPARK-27356) File source V2: return actual schema in method `FileScan.readSchema`

Gengliang Wang created SPARK-27356:
--------------------------------------

             Summary: File source V2: return actual schema in method `FileScan.readSchema`
                 Key: SPARK-27356
                 URL: https://issues.apache.org/jira/browse/SPARK-27356
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 3.0.0
            Reporter: Gengliang Wang


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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org