{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/12590","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/12590/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/12590/comments","events_url":"https://api.github.com/repos/apache/spark/issues/12590/events","html_url":"https://github.com/apache/spark/pull/12590","id":150224789,"number":12590,"title":"[SPARK-14830][SQL] Add RemoveRepetitionFromGroupExpressions optimizer.","user":{"login":"dongjoon-hyun","id":9700541,"avatar_url":"https://avatars.githubusercontent.com/u/9700541?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjoon-hyun","html_url":"https://github.com/dongjoon-hyun","followers_url":"https://api.github.com/users/dongjoon-hyun/followers","following_url":"https://api.github.com/users/dongjoon-hyun/following{/other_user}","gists_url":"https://api.github.com/users/dongjoon-hyun/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjoon-hyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjoon-hyun/subscriptions","organizations_url":"https://api.github.com/users/dongjoon-hyun/orgs","repos_url":"https://api.github.com/users/dongjoon-hyun/repos","events_url":"https://api.github.com/users/dongjoon-hyun/events{/privacy}","received_events_url":"https://api.github.com/users/dongjoon-hyun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-22T00:11:28Z","updated_at":"2016-04-25T09:07:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12590","html_url":"https://github.com/apache/spark/pull/12590","diff_url":"https://github.com/apache/spark/pull/12590.diff","patch_url":"https://github.com/apache/spark/pull/12590.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\nThis PR aims to optimize GroupExpressions by removing repeating expressions.\r\n`RemoveRepetitionFromGroupExpressions` is added.\r\n\r\n**Before**\r\n```scala\r\nscala> sql(\"select a from (select explode(array(1,2)) a) T group by a, a, a\").explain()\r\n== Physical Plan ==\r\nWholeStageCodegen\r\n:  +- TungstenAggregate(key=[a#5,a#5,a#5], functions=[], output=[a#5])\r\n:     +- INPUT\r\n+- Exchange hashpartitioning(a#5, a#5, a#5, 200), None\r\n   +- WholeStageCodegen\r\n      :  +- TungstenAggregate(key=[a#5,a#5,a#5], functions=[], output=[a#5,a#5,a#5])\r\n      :     +- INPUT\r\n      +- Generate explode([1,2]), false, false, [a#5]\r\n         +- Scan OneRowRelation[]\r\n```\r\n\r\n**After**\r\n```scala\r\nscala> sql(\"select a from (select explode(array(1,2)) a) T group by a, a, a\").explain()\r\n== Physical Plan ==\r\nWholeStageCodegen\r\n:  +- TungstenAggregate(key=[a#5], functions=[], output=[a#5])\r\n:     +- INPUT\r\n+- Exchange hashpartitioning(a#5, 200), None\r\n   +- WholeStageCodegen\r\n      :  +- TungstenAggregate(key=[a#5], functions=[], output=[a#5])\r\n      :     +- INPUT\r\n      +- Generate explode([1,2]), false, false, [a#5]\r\n         +- Scan OneRowRelation[]\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nPass the Jenkins tests (with a new testcase)"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/214219497","html_url":"https://github.com/apache/spark/pull/12590#issuecomment-214219497","issue_url":"https://api.github.com/repos/apache/spark/issues/12590","id":214219497,"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-04-25T09:07:37Z","updated_at":"2016-04-25T09:07:37Z","body":"**[Test build #56891 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/56891/consoleFull)** for PR 12590 at commit [`78a42c5`](https://github.com/apache/spark/commit/78a42c5c082a49bec078be4c23570ecb0489e900)."}}