{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/11100","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/11100/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/11100/comments","events_url":"https://api.github.com/repos/apache/spark/issues/11100/events","html_url":"https://github.com/apache/spark/pull/11100","id":131807710,"number":11100,"title":"[SPARK-13221] [SQL] Fixing GroupingSets when Aggregate Functions Containing GroupBy Columns","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":13,"created_at":"2016-02-06T01:58:32Z","updated_at":"2016-02-08T06:36:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11100","html_url":"https://github.com/apache/spark/pull/11100","diff_url":"https://github.com/apache/spark/pull/11100.diff","patch_url":"https://github.com/apache/spark/pull/11100.patch"},"body":"Using GroupingSets will generate a wrong result when Aggregate Functions containing GroupBy columns. \r\n\r\nThis PR is to fix it. Since the code changes are very small. Maybe we also can merge it to 1.6\r\n\r\nThanks!\r\n\r\nFor example, the following query returns a wrong result:\r\n```scala\r\nsql(\"select course, sum(earnings) as sum from courseSales group by course, earnings\" +\r\n     \" grouping sets((), (course), (course, earnings))\" +\r\n     \" order by course, sum\").show()\r\n```\r\nBefore the fix, the results are like\r\n```\r\n[null,null]\r\n[Java,null]\r\n[Java,20000.0]\r\n[Java,30000.0]\r\n[dotNET,null]\r\n[dotNET,5000.0]\r\n[dotNET,10000.0]\r\n[dotNET,48000.0]\r\n```\r\nAfter the fix, the results become correct:\r\n```\r\n[null,113000.0]\r\n[Java,20000.0]\r\n[Java,30000.0]\r\n[Java,50000.0]\r\n[dotNET,5000.0]\r\n[dotNET,10000.0]\r\n[dotNET,48000.0]\r\n[dotNET,63000.0]\r\n```"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/181226826","html_url":"https://github.com/apache/spark/pull/11100#issuecomment-181226826","issue_url":"https://api.github.com/repos/apache/spark/issues/11100","id":181226826,"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-02-08T06:36:36Z","updated_at":"2016-02-08T06:36:36Z","body":"**[Test build #50910 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/50910/consoleFull)** for PR 11100 at commit [`114e0eb`](https://github.com/apache/spark/commit/114e0eba1fbdf28e359f15bedacb7defa1998be6).\n * This patch **fails Spark unit tests**.\n * This patch merges cleanly.\n * This patch adds no public classes."}}