GitHub user gatorsmile opened a pull request: https://github.com/apache/spark/pull/14322
[SPARK-16689] [SQL] FileSourceStrategy: Pruning Partition Columns When No Partition Column Exist in Project ### What changes were proposed in this pull request? For partitioned file sources, the current implementation always scans all the partition columns. However, this is not necessary when the projected column list does not include any partition column. In addition, we also can avoid the unnecessary Project. Below is an example, Below is an example, ```scala spark .range(N) .selectExpr("id AS value1", "id AS value2", "id AS p1", "id AS p2", "id AS p3") .toDF("value", "value2", "p1", "p2", "p3").write.format("json") .partitionBy("p1", "p2", "p3").save(tempDir) ``` ``` spark.read.format("json").load(tempDir).selectExpr("value") ``` **Before the PR changes**, the physical plan is like: ``` == Physical Plan == *Project [value#37L] +- *Scan json [value#37L,p1#39,p2#40,p3#41] Format: JSON, InputPaths: file:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-f7a4294a-2e1b-4f44-9ebb-1a5eb..., PushedFilters: [], ReadSchema: struct<value:bigint> ``` **After the PR changes**, the physical plan becomes: ``` == Physical Plan == *Scan json [value#147L] Format: JSON, InputPaths: file:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-a5bcb14a-46c2-4c20-8f34-9662b..., PushedFilters: [], ReadSchema: struct<value:bigint> ``` ### How was this patch tested? Added a test case to verify the results. You can merge this pull request into a Git repository by running: $ git pull https://github.com/gatorsmile/spark columnPruning Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/14322.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #14322 ---- commit c1ff0465815f6adefb2b29c2973c9bc63aa13623 Author: gatorsmile <gatorsm...@gmail.com> Date: 2016-07-23T00:59:14Z solution1 ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org