{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/14957","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/14957/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/14957/comments","events_url":"https://api.github.com/repos/apache/spark/issues/14957/events","html_url":"https://github.com/apache/spark/pull/14957","id":175024017,"number":14957,"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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-09-05T08:49:54Z","updated_at":"2016-10-26T03:37:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14957","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"},"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`"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/256241521","html_url":"https://github.com/apache/spark/pull/14957#issuecomment-256241521","issue_url":"https://api.github.com/repos/apache/spark/issues/14957","id":256241521,"user":{"login":"SparkQA","id":8108735,"avatar_url":"https://avatars.githubusercontent.com/u/8108735?v=3","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T03:37:42Z","updated_at":"2016-10-26T03:37:42Z","body":"**[Test build #67550 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67550/consoleFull)** for PR 14957 at commit [`5697911`](https://github.com/apache/spark/commit/56979118bfee1f2de3ac22c52280e8b36a14fc38)."}}
{"actor":{"display_login":"SparkQA"}}