{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/11599","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/11599/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/11599/comments","events_url":"https://api.github.com/repos/apache/spark/issues/11599/events","html_url":"https://github.com/apache/spark/pull/11599","id":139472160,"number":11599,"title":"[SPARK-13763] [SQL] Remove Project when its projectList is Empty","user":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-09T04:24:36Z","updated_at":"2016-03-09T05:54:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11599","html_url":"https://github.com/apache/spark/pull/11599","diff_url":"https://github.com/apache/spark/pull/11599.diff","patch_url":"https://github.com/apache/spark/pull/11599.patch"},"body":"#### What changes were proposed in this pull request?\r\n\r\nAs shown in another PR: https://github.com/apache/spark/pull/11596, we are using `SELECT 1` as a dummy table, when the table is used for SQL statements in which a table reference is required, but the contents of the table are not important. For example,\r\n\r\n```SQL\r\nSELECT value FROM (select 1) dummyTable Lateral View explode(array(1,2,3)) adTable as value\r\n```\r\nBefore the PR, the optimized plan contains a useless `Project` after Optimizer executing the `ColumnPruning` rule, as shown below:\r\n\r\n```\r\n== Analyzed Logical Plan ==\r\nvalue: int\r\nProject [value#22]\r\n+- Generate explode(array(1, 2, 3)), true, false, Some(adtable), [value#22]\r\n   +- SubqueryAlias dummyTable\r\n      +- Project [1 AS 1#21]\r\n         +- OneRowRelation$\r\n\r\n== Optimized Logical Plan ==\r\nGenerate explode([1,2,3]), false, false, Some(adtable), [value#22]\r\n+- Project\r\n   +- OneRowRelation$\r\n```\r\n\r\nAfter the fix, the optimized plan removed the useless `Project`, as shown below:\r\n```\r\n== Optimized Logical Plan ==\r\nGenerate explode([1,2,3]), false, false, Some(adtable), [value#22]\r\n+- OneRowRelation$\r\n```\r\n\r\n#### How was this patch tested?\r\n\r\nAdded a new unit test case into the suite `ColumnPruningSuite.scala`"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/194126222","html_url":"https://github.com/apache/spark/pull/11599#issuecomment-194126222","issue_url":"https://api.github.com/repos/apache/spark/issues/11599","id":194126222,"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-03-09T05:54:12Z","updated_at":"2016-03-09T05:54:12Z","body":"**[Test build #52721 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52721/consoleFull)** for PR 11599 at commit [`0fa21ac`](https://github.com/apache/spark/commit/0fa21acd2614fbdf128561b34c72088008d62a05).\n * This patch passes all tests.\n * This patch merges cleanly.\n * This patch adds no public classes."}}