{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/13358","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/13358/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/13358/comments","events_url":"https://api.github.com/repos/apache/spark/issues/13358/events","html_url":"https://github.com/apache/spark/pull/13358","id":157176970,"number":13358,"title":"[SPARK-15612][SQL] Raise exception if decimal `scale` >= `precision`","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":4,"created_at":"2016-05-27T10:29:32Z","updated_at":"2016-05-27T10:39:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13358","html_url":"https://github.com/apache/spark/pull/13358","diff_url":"https://github.com/apache/spark/pull/13358.diff","patch_url":"https://github.com/apache/spark/pull/13358.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\nCurrently, Spark raises exceptions only when decimal `scale` > `precision`. However, the value becames `null` if `scale` = `precision`. We should raise exceptions for that case, too.\r\n\r\n**Before**\r\n```scala\r\nscala> sql(\"select cast('1' as Decimal(2,1))\")\r\nres0: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(2,1)): decimal(2,1)]\r\n\r\nscala> sql(\"select cast('1' as Decimal(2,2))\")\r\nres1: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(2,2)): decimal(2,2)]\r\n\r\nscala> sql(\"select cast('1' as Decimal(2,3))\")\r\norg.apache.spark.sql.catalyst.parser.ParseException:\r\nDecimal scale (3) cannot be greater than precision (2).\r\n\r\nscala> sql(\"select cast('1' as Decimal(2,1))\").head\r\nres2: org.apache.spark.sql.Row = [1.0]\r\n\r\nscala> sql(\"select cast('1' as Decimal(2,2))\").head\r\nres3: org.apache.spark.sql.Row = [null]\r\n```\r\n\r\n**After**\r\n```scala\r\nscala> sql(\"select cast('1' as Decimal(2,1))\")\r\nres0: org.apache.spark.sql.DataFrame = [CAST(1 AS DECIMAL(2,1)): decimal(2,1)]\r\n\r\nscala> sql(\"select cast('1' as Decimal(2,2))\")\r\norg.apache.spark.sql.catalyst.parser.ParseException:\r\nDecimal scale (2) must be less than precision (2).\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/222115736","html_url":"https://github.com/apache/spark/pull/13358#issuecomment-222115736","issue_url":"https://api.github.com/repos/apache/spark/issues/13358","id":222115736,"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-05-27T10:39:30Z","updated_at":"2016-05-27T10:39:30Z","body":"Test FAILed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/59486/\nTest FAILed."}}
{"actor":{"display_login":"AmplabJenkins"}}