{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/77844084","id":77844084,"diff_hunk":"@@ -97,7 +98,16 @@ object FileSourceStrategy extends Strategy with Logging {\n         dataColumns\n           .filter(requiredAttributes.contains)\n           .filterNot(partitionColumns.contains)\n-      val outputSchema = readDataColumns.toStructType\n+      val outputSchema = if (fsRelation.sqlContext.conf.isParquetNestColumnPruning) {","path":"sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala","position":13,"original_position":13,"commit_id":"1c348779d4f7fff4de677b52a995330c9cfb6d03","original_commit_id":"46c2474ca76ee190ec9333eeae22eb010dce0195","user":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"body":"I run all datasource tests by \r\n`./build/sbt \"test-only org.apache.spark.sql.execution.datasources.*\"`\r\nthree test failed, but run them seperately, all tests can passwd","created_at":"2016-09-07T15:20:28Z","updated_at":"2016-09-07T15:20:28Z","html_url":"https://github.com/apache/spark/pull/14957#discussion_r77844084","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/14957","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/77844084"},"html":{"href":"https://github.com/apache/spark/pull/14957#discussion_r77844084"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/14957"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14957","id":83968776,"html_url":"https://github.com/apache/spark/pull/14957","diff_url":"https://github.com/apache/spark/pull/14957.diff","patch_url":"https://github.com/apache/spark/pull/14957.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/14957","number":14957,"state":"open","locked":false,"title":"[SPARK-4502][SQL]Support parquet nested struct pruning and add relevant test","user":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nLike the description in  [SPARK-4502](https://issues.apache.org/jira/browse/SPARK-4502), we have the same problem in Baidu and our user's parquet file has complex nested parquet struct(400+ fields and 4 layer nested) so this problem brings unnecessary data read and time spend. This pr fixed the problem and main fix ideas list as follows:\r\n\r\n1.  Add booleanConf `spark.sql.parquet.nestColumnPruning`, when it’s closed, same logical with before\r\n\r\n2.  In `FileSourceStrategy`, traverse `projects[NamedExpression]` and generate the access path of nested struct.\r\nFor example:  in query `select people.addr.city from table`\r\nproject getStructField('city', getStructField('addr', AttributeRefence('people'))) will have the access path ['people', 'addr', 'city']\r\n\r\n3. get StructField recursively by the access path\r\n\r\n4. Merge structType of fields in same structType and merge filter attributes\r\nFor example:  the json format of struct type \r\n```\r\nroot\r\n    |-- people: struct (nullable = true)\r\n    |-- addr: struct (nullable = true)\r\n    |    |-- city: string (nullable = true)\r\n```\r\nand\r\n```\r\nroot\r\n    |-- people: struct (nullable = true)\r\n    |-- addr: struct (nullable = true)\r\n    |    |-- zip_code: string (nullable = true)\r\n```\r\nwill merge to \r\n```\r\nroot\r\n    |-- people: struct (nullable = true)\r\n    |-- addr: struct (nullable = true)\r\n    |    |-- city: string (nullable = true)\r\n    |    |-- zip_code: string (nullable = true)\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nadd new test in `ParquetQuerySuite`","created_at":"2016-09-05T08:49:54Z","updated_at":"2016-09-07T15:20:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c38ad092b4eea50ab61079b2f1d89efecf5f774","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/14957/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/14957/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/14957/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/1c348779d4f7fff4de677b52a995330c9cfb6d03","head":{"label":"xuanyuanking:SPARK-4502","ref":"SPARK-4502","sha":"1c348779d4f7fff4de677b52a995330c9cfb6d03","user":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"repo":{"id":52511431,"name":"spark","full_name":"xuanyuanking/spark","owner":{"login":"xuanyuanking","id":4833765,"avatar_url":"https://avatars.githubusercontent.com/u/4833765?v=3","gravatar_id":"","url":"https://api.github.com/users/xuanyuanking","html_url":"https://github.com/xuanyuanking","followers_url":"https://api.github.com/users/xuanyuanking/followers","following_url":"https://api.github.com/users/xuanyuanking/following{/other_user}","gists_url":"https://api.github.com/users/xuanyuanking/gists{/gist_id}","starred_url":"https://api.github.com/users/xuanyuanking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuanyuanking/subscriptions","organizations_url":"https://api.github.com/users/xuanyuanking/orgs","repos_url":"https://api.github.com/users/xuanyuanking/repos","events_url":"https://api.github.com/users/xuanyuanking/events{/privacy}","received_events_url":"https://api.github.com/users/xuanyuanking/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xuanyuanking/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/xuanyuanking/spark","forks_url":"https://api.github.com/repos/xuanyuanking/spark/forks","keys_url":"https://api.github.com/repos/xuanyuanking/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xuanyuanking/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xuanyuanking/spark/teams","hooks_url":"https://api.github.com/repos/xuanyuanking/spark/hooks","issue_events_url":"https://api.github.com/repos/xuanyuanking/spark/issues/events{/number}","events_url":"https://api.github.com/repos/xuanyuanking/spark/events","assignees_url":"https://api.github.com/repos/xuanyuanking/spark/assignees{/user}","branches_url":"https://api.github.com/repos/xuanyuanking/spark/branches{/branch}","tags_url":"https://api.github.com/repos/xuanyuanking/spark/tags","blobs_url":"https://api.github.com/repos/xuanyuanking/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xuanyuanking/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xuanyuanking/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/xuanyuanking/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xuanyuanking/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/xuanyuanking/spark/languages","stargazers_url":"https://api.github.com/repos/xuanyuanking/spark/stargazers","contributors_url":"https://api.github.com/repos/xuanyuanking/spark/contributors","subscribers_url":"https://api.github.com/repos/xuanyuanking/spark/subscribers","subscription_url":"https://api.github.com/repos/xuanyuanking/spark/subscription","commits_url":"https://api.github.com/repos/xuanyuanking/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/xuanyuanking/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/xuanyuanking/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/xuanyuanking/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/xuanyuanking/spark/contents/{+path}","compare_url":"https://api.github.com/repos/xuanyuanking/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xuanyuanking/spark/merges","archive_url":"https://api.github.com/repos/xuanyuanking/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xuanyuanking/spark/downloads","issues_url":"https://api.github.com/repos/xuanyuanking/spark/issues{/number}","pulls_url":"https://api.github.com/repos/xuanyuanking/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/xuanyuanking/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/xuanyuanking/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xuanyuanking/spark/labels{/name}","releases_url":"https://api.github.com/repos/xuanyuanking/spark/releases{/id}","deployments_url":"https://api.github.com/repos/xuanyuanking/spark/deployments","created_at":"2016-02-25T09:08:00Z","updated_at":"2016-02-25T09:08:28Z","pushed_at":"2016-09-07T12:07:23Z","git_url":"git://github.com/xuanyuanking/spark.git","ssh_url":"git@github.com:xuanyuanking/spark.git","clone_url":"https://github.com/xuanyuanking/spark.git","svn_url":"https://github.com/xuanyuanking/spark","homepage":null,"size":185025,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"3ccb23e445711ea5d9059eb6de7c490c8fc9d112","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-09-07T15:14:05Z","pushed_at":"2016-09-07T13:55:30Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":523515,"stargazers_count":9922,"watchers_count":9922,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9243,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":472,"forks":9243,"open_issues":472,"watchers":9922,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/14957"},"html":{"href":"https://github.com/apache/spark/pull/14957"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/14957"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/14957/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/14957/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/14957/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/1c348779d4f7fff4de677b52a995330c9cfb6d03"}}}}
{"actor":{"display_login":"xuanyuanking"}}