{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/26934440","id":26934440,"diff_hunk":"@@ -198,6 +203,44 @@ class SqlParser extends AbstractSparkSQLParser with DataTypeParser {\n     | FULL  ~ OUTER.? ^^^ FullOuter\n     )\n \n+  protected lazy val groupType: Parser[(LogicalPlan, Seq[NamedExpression]) => LogicalPlan] =\n+    GROUP ~ BY ~> (\n+      rep1sep(expression, \",\") <~ WITH ~ ROLLUP ^^ { case r =>\n+        (child: LogicalPlan, aggregations: Seq[NamedExpression]) =>\n+          Rollup(r, child, aggregations)\n+      }\n+      | rep1sep(expression, \",\") <~ WITH ~ CUBE ^^ { case c =>\n+          (child: LogicalPlan, aggregations: Seq[NamedExpression]) =>\n+            Cube(c, child, aggregations)\n+      }\n+      | rep1sep(expression, \",\") ~ (GROUPING ~ SETS ~ \"(\" ~> rep1sep(groupingsets, \",\") <~ \")\")\n+          ^^ { case e ~ g =>\n+          (child: LogicalPlan, aggregations: Seq[NamedExpression]) =>\n+            calGroupingSets(child, aggregations, g, Some(e))\n+      }\n+      | rep1sep(expression, \",\") ^^ { case g =>\n+          (child: LogicalPlan, aggregations: Seq[NamedExpression]) =>\n+            Aggregate(g, aggregations, child)\n+      }\n+    )\n+\n+  protected lazy val groupingsets: Parser[Seq[Expression]] =\n+    ( \"(\" ~> repsep(expression, \",\") <~ \")\"\n+    | rep1sep(expression, \",\")\n+    )\n+\n+  private def calGroupingSets(child: LogicalPlan, aggregations: Seq[NamedExpression],","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SqlParser.scala","position":83,"original_position":83,"commit_id":"238a7828d5a862e62c15832a0503745385d553c7","original_commit_id":"238a7828d5a862e62c15832a0503745385d553c7","user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"body":"Each argument per line.","created_at":"2015-03-23T13:11:37Z","updated_at":"2015-03-23T13:11:37Z","html_url":"https://github.com/apache/spark/pull/5080#discussion_r26934440","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/5080","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/26934440"},"html":{"href":"https://github.com/apache/spark/pull/5080#discussion_r26934440"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/5080"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/5080","id":31397126,"html_url":"https://github.com/apache/spark/pull/5080","diff_url":"https://github.com/apache/spark/pull/5080.diff","patch_url":"https://github.com/apache/spark/pull/5080.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/5080","number":5080,"state":"open","locked":false,"title":"[SPARK-6356][SQL] Support the ROLLUP/CUBE/GROUPING SETS in SQLContext","user":{"login":"watermen","id":1400819,"avatar_url":"https://avatars.githubusercontent.com/u/1400819?v=3","gravatar_id":"","url":"https://api.github.com/users/watermen","html_url":"https://github.com/watermen","followers_url":"https://api.github.com/users/watermen/followers","following_url":"https://api.github.com/users/watermen/following{/other_user}","gists_url":"https://api.github.com/users/watermen/gists{/gist_id}","starred_url":"https://api.github.com/users/watermen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watermen/subscriptions","organizations_url":"https://api.github.com/users/watermen/orgs","repos_url":"https://api.github.com/users/watermen/repos","events_url":"https://api.github.com/users/watermen/events{/privacy}","received_events_url":"https://api.github.com/users/watermen/received_events","type":"User","site_admin":false},"body":"Support for the syntax(also supported by HiveContext) below:\r\n```\r\nGROUP BY expression list WITH ROLLUP\r\nGROUP BY expression list WITH CUBE\r\nGROUP BY expression list GROUPING SETS(expression list2)\r\n```\r\n\r\nhttps://github.com/apache/spark/pull/5045\r\n\r\n/cc @yhuai","created_at":"2015-03-18T03:04:25Z","updated_at":"2015-03-23T13:11:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6f396a7ab693353d04662cf7241c3ad68e3cefa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/5080/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/5080/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/5080/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/238a7828d5a862e62c15832a0503745385d553c7","head":{"label":"watermen:sql_grouping_sets","ref":"sql_grouping_sets","sha":"238a7828d5a862e62c15832a0503745385d553c7","user":{"login":"watermen","id":1400819,"avatar_url":"https://avatars.githubusercontent.com/u/1400819?v=3","gravatar_id":"","url":"https://api.github.com/users/watermen","html_url":"https://github.com/watermen","followers_url":"https://api.github.com/users/watermen/followers","following_url":"https://api.github.com/users/watermen/following{/other_user}","gists_url":"https://api.github.com/users/watermen/gists{/gist_id}","starred_url":"https://api.github.com/users/watermen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watermen/subscriptions","organizations_url":"https://api.github.com/users/watermen/orgs","repos_url":"https://api.github.com/users/watermen/repos","events_url":"https://api.github.com/users/watermen/events{/privacy}","received_events_url":"https://api.github.com/users/watermen/received_events","type":"User","site_admin":false},"repo":{"id":26309097,"name":"spark","full_name":"watermen/spark","owner":{"login":"watermen","id":1400819,"avatar_url":"https://avatars.githubusercontent.com/u/1400819?v=3","gravatar_id":"","url":"https://api.github.com/users/watermen","html_url":"https://github.com/watermen","followers_url":"https://api.github.com/users/watermen/followers","following_url":"https://api.github.com/users/watermen/following{/other_user}","gists_url":"https://api.github.com/users/watermen/gists{/gist_id}","starred_url":"https://api.github.com/users/watermen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/watermen/subscriptions","organizations_url":"https://api.github.com/users/watermen/orgs","repos_url":"https://api.github.com/users/watermen/repos","events_url":"https://api.github.com/users/watermen/events{/privacy}","received_events_url":"https://api.github.com/users/watermen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/watermen/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/watermen/spark","forks_url":"https://api.github.com/repos/watermen/spark/forks","keys_url":"https://api.github.com/repos/watermen/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/watermen/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/watermen/spark/teams","hooks_url":"https://api.github.com/repos/watermen/spark/hooks","issue_events_url":"https://api.github.com/repos/watermen/spark/issues/events{/number}","events_url":"https://api.github.com/repos/watermen/spark/events","assignees_url":"https://api.github.com/repos/watermen/spark/assignees{/user}","branches_url":"https://api.github.com/repos/watermen/spark/branches{/branch}","tags_url":"https://api.github.com/repos/watermen/spark/tags","blobs_url":"https://api.github.com/repos/watermen/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/watermen/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/watermen/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/watermen/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/watermen/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/watermen/spark/languages","stargazers_url":"https://api.github.com/repos/watermen/spark/stargazers","contributors_url":"https://api.github.com/repos/watermen/spark/contributors","subscribers_url":"https://api.github.com/repos/watermen/spark/subscribers","subscription_url":"https://api.github.com/repos/watermen/spark/subscription","commits_url":"https://api.github.com/repos/watermen/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/watermen/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/watermen/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/watermen/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/watermen/spark/contents/{+path}","compare_url":"https://api.github.com/repos/watermen/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/watermen/spark/merges","archive_url":"https://api.github.com/repos/watermen/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/watermen/spark/downloads","issues_url":"https://api.github.com/repos/watermen/spark/issues{/number}","pulls_url":"https://api.github.com/repos/watermen/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/watermen/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/watermen/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/watermen/spark/labels{/name}","releases_url":"https://api.github.com/repos/watermen/spark/releases{/id}","created_at":"2014-11-07T07:37:56Z","updated_at":"2015-02-04T02:18:35Z","pushed_at":"2015-03-23T08:58:24Z","git_url":"git://github.com/watermen/spark.git","ssh_url":"git@github.com:watermen/spark.git","clone_url":"https://github.com/watermen/spark.git","svn_url":"https://github.com/watermen/spark","homepage":null,"size":92974,"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":"bf044def4c3a37a0fd4d5e70c2d57685cfd9fd71","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-03-23T13:01:24Z","pushed_at":"2015-03-23T12:57:55Z","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":1404458,"stargazers_count":3332,"watchers_count":3332,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2868,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":289,"forks":2868,"open_issues":289,"watchers":3332,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/5080"},"html":{"href":"https://github.com/apache/spark/pull/5080"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/5080"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/5080/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/5080/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/5080/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/238a7828d5a862e62c15832a0503745385d553c7"}}}}