{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/15980","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/15980/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/15980/comments","events_url":"https://api.github.com/repos/apache/spark/issues/15980/events","html_url":"https://github.com/apache/spark/pull/15980","id":191105390,"number":15980,"title":"[SPARK-18528][SQL] Fix a bug to initialise an iterator of aggregation buffer ","user":{"login":"maropu","id":692303,"avatar_url":"https://avatars.githubusercontent.com/u/692303?v=3","gravatar_id":"","url":"https://api.github.com/users/maropu","html_url":"https://github.com/maropu","followers_url":"https://api.github.com/users/maropu/followers","following_url":"https://api.github.com/users/maropu/following{/other_user}","gists_url":"https://api.github.com/users/maropu/gists{/gist_id}","starred_url":"https://api.github.com/users/maropu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maropu/subscriptions","organizations_url":"https://api.github.com/users/maropu/orgs","repos_url":"https://api.github.com/users/maropu/repos","events_url":"https://api.github.com/users/maropu/events{/privacy}","received_events_url":"https://api.github.com/users/maropu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-22T19:43:31Z","updated_at":"2016-11-23T16:45:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/15980","html_url":"https://github.com/apache/spark/pull/15980","diff_url":"https://github.com/apache/spark/pull/15980.diff","patch_url":"https://github.com/apache/spark/pull/15980.patch"},"body":"## What changes were proposed in this pull request?\r\nThis pr is to fix an `NullPointerException` issue caused by a following `limit + aggregate` query;\r\n```\r\nscala> val df = Seq((\"a\", 1), (\"b\", 2), (\"c\", 1), (\"d\", 5)).toDF(\"id\", \"value\")\r\nscala> df.limit(2).groupBy(\"id\").count().show\r\nWARN TaskSetManager: Lost task 0.0 in stage 9.0 (TID 8204, lvsp20hdn012.stubprod.com): java.lang.NullPointerException\r\nat org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.agg_doAggregateWithKeys$(Unknown Source)\r\nat org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.processNext(Unknown Source)\r\n```\r\nThe root culprit is that [`$doAgg()`](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L596) skips an initialization of [the buffer iterator](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L603); `BaseLimitExec` sets `stopEarly=true` and `$doAgg()` exits in the middle without the initialization.\r\n\r\n## How was this patch tested?\r\nAdded a test to check if no exception happens for limit + aggregates in `DataFrameAggregateSuite.scala`.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/262568434","html_url":"https://github.com/apache/spark/pull/15980#issuecomment-262568434","issue_url":"https://api.github.com/repos/apache/spark/issues/15980","id":262568434,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T16:45:13Z","updated_at":"2016-11-23T16:45:13Z","body":"Test PASSed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/69078/\nTest PASSed."}}
{"actor":{"display_login":"AmplabJenkins"}}