{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/13651","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/13651/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/13651/comments","events_url":"https://api.github.com/repos/apache/spark/issues/13651/events","html_url":"https://github.com/apache/spark/pull/13651","id":160057636,"number":13651,"title":"[SPARK-15776][SQL] Divide Expression inside Aggregation function is casted to wrong type","user":{"login":"clockfly","id":2595532,"avatar_url":"https://avatars.githubusercontent.com/u/2595532?v=3","gravatar_id":"","url":"https://api.github.com/users/clockfly","html_url":"https://github.com/clockfly","followers_url":"https://api.github.com/users/clockfly/followers","following_url":"https://api.github.com/users/clockfly/following{/other_user}","gists_url":"https://api.github.com/users/clockfly/gists{/gist_id}","starred_url":"https://api.github.com/users/clockfly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clockfly/subscriptions","organizations_url":"https://api.github.com/users/clockfly/orgs","repos_url":"https://api.github.com/users/clockfly/repos","events_url":"https://api.github.com/users/clockfly/events{/privacy}","received_events_url":"https://api.github.com/users/clockfly/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2016-06-13T22:18:44Z","updated_at":"2016-06-15T00:34:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13651","html_url":"https://github.com/apache/spark/pull/13651","diff_url":"https://github.com/apache/spark/pull/13651.diff","patch_url":"https://github.com/apache/spark/pull/13651.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\nThis PR fixes the problem that Divide Expression inside Aggregation function is casted to wrong type, which cause `select 1/2` and `select sum(1/2)`returning different result.\r\n\r\n**Before the change:**\r\n\r\n```\r\nscala> sql(\"select 1/2 as a\").show()\r\n+---+\r\n|  a|\r\n+---+\r\n|0.5|\r\n+---+\r\n\r\nscala> sql(\"select sum(1/2) as a\").show()\r\n+---+\r\n|  a|\r\n+---+\r\n|0  |\r\n+---+\r\n\r\nscala> sql(\"select sum(1 / 2) as a\").schema\r\nres4: org.apache.spark.sql.types.StructType = StructType(StructField(a,LongType,true))\r\n```\r\n\r\n**After the change:**\r\n\r\n```\r\nscala> sql(\"select 1/2 as a\").show()\r\n+---+\r\n|  a|\r\n+---+\r\n|0.5|\r\n+---+\r\n\r\nscala> sql(\"select sum(1/2) as a\").show()\r\n+---+\r\n|  a|\r\n+---+\r\n|0.5|\r\n+---+\r\n\r\nscala> sql(\"select sum(1/2) as a\").schema\r\nres4: org.apache.spark.sql.types.StructType = StructType(StructField(a,DoubleType,true))\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nUnit test.\r\n\r\nThis PR is based on https://github.com/apache/spark/pull/13524 by @Sephiroth-Lin"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/226056854","html_url":"https://github.com/apache/spark/pull/13651#issuecomment-226056854","issue_url":"https://api.github.com/repos/apache/spark/issues/13651","id":226056854,"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-06-15T00:34:01Z","updated_at":"2016-06-15T00:34:01Z","body":"**[Test build #60529 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/60529/consoleFull)** for PR 13651 at commit [`3dd03b7`](https://github.com/apache/spark/commit/3dd03b7a716b76e55ccf142a9a1afa237f312cf5).\n * This patch **fails Spark unit tests**.\n * This patch merges cleanly.\n * This patch adds no public classes."}}
{"actor":{"display_login":"SparkQA"}}