{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/52897976","id":52897976,"diff_hunk":"@@ -107,6 +161,44 @@ public static double ceiling(@SqlType(StandardTypes.DOUBLE) double num)\n         return Math.ceil(num);\n     }\n \n+    private static SqlScalarFunction decimalCeilingFunction(String name)\n+    {\n+        Signature signature = Signature.builder()\n+                .kind(SCALAR)\n+                .name(name)\n+                .literalParameters(\"num_precision\", \"num_scale\")\n+                .argumentTypes(\"decimal(num_precision, num_scale)\")\n+                .returnType(\"decimal(num_precision, num_scale)\")\n+                .build();\n+        return SqlScalarFunction.builder(MathFunctions.class)\n+                .signature(signature)\n+                .methods(\"ceilingShortDecimal\", \"ceilingLongDecimal\")\n+                .extraParameters(MathFunctions::decimalScaleExtraParameters)\n+                .build();\n+    }\n+\n+    private static List<Object> decimalScaleExtraParameters(SpecializeContext context)\n+    {\n+        return ImmutableList.of(context.getLiteral(\"num_scale\"));\n+    }\n+\n+    public static long ceilingShortDecimal(long num, long scale)\n+    {\n+        BigDecimal bigDecimal = BigDecimal.valueOf(num, (int) scale);","path":"presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java","position":114,"original_position":114,"commit_id":"0fd079ed539ed998af4eaa58a23fc918949ba98c","original_commit_id":"0fd079ed539ed998af4eaa58a23fc918949ba98c","user":{"login":"losipiuk","id":890111,"avatar_url":"https://avatars.githubusercontent.com/u/890111?v=3","gravatar_id":"","url":"https://api.github.com/users/losipiuk","html_url":"https://github.com/losipiuk","followers_url":"https://api.github.com/users/losipiuk/followers","following_url":"https://api.github.com/users/losipiuk/following{/other_user}","gists_url":"https://api.github.com/users/losipiuk/gists{/gist_id}","starred_url":"https://api.github.com/users/losipiuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/losipiuk/subscriptions","organizations_url":"https://api.github.com/users/losipiuk/orgs","repos_url":"https://api.github.com/users/losipiuk/repos","events_url":"https://api.github.com/users/losipiuk/events{/privacy}","received_events_url":"https://api.github.com/users/losipiuk/received_events","type":"User","site_admin":false},"body":"do not create BigDecimal here.\r\nPossibly you also want to pass some derivate of scale as parameter here - to avoid repeated computations for each row.","created_at":"2016-02-15T13:28:15Z","updated_at":"2016-02-15T13:28:15Z","html_url":"https://github.com/Teradata/presto/pull/115#discussion_r52897976","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/115","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/52897976"},"html":{"href":"https://github.com/Teradata/presto/pull/115#discussion_r52897976"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/115"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/115","id":58020532,"html_url":"https://github.com/Teradata/presto/pull/115","diff_url":"https://github.com/Teradata/presto/pull/115.diff","patch_url":"https://github.com/Teradata/presto/pull/115.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/115","number":115,"state":"open","locked":false,"title":"functions for decimal(p,s)","user":{"login":"ilfrin","id":6389448,"avatar_url":"https://avatars.githubusercontent.com/u/6389448?v=3","gravatar_id":"","url":"https://api.github.com/users/ilfrin","html_url":"https://github.com/ilfrin","followers_url":"https://api.github.com/users/ilfrin/followers","following_url":"https://api.github.com/users/ilfrin/following{/other_user}","gists_url":"https://api.github.com/users/ilfrin/gists{/gist_id}","starred_url":"https://api.github.com/users/ilfrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilfrin/subscriptions","organizations_url":"https://api.github.com/users/ilfrin/orgs","repos_url":"https://api.github.com/users/ilfrin/repos","events_url":"https://api.github.com/users/ilfrin/events{/privacy}","received_events_url":"https://api.github.com/users/ilfrin/received_events","type":"User","site_admin":false},"body":"reviewers: pnowojski, losipiuk\r\n\r\nThis set of commits introduces functions (aggregate and scalar) for decimal(p,s). \r\n\r\nThe implementation for aggregate function uses the \"old\" way (overriding specialize()). Once the \"new way\", the annotation framework for aggregate functions, accommodates parametrised types this should be refactored to leverage that.  \r\n\r\nThe scalar functions are implemented using the builder approach.\r\n\r\nMost implementations use BigDecimal and BigInteger freely. Once there is a fast LongDecimalType implementation we can look to those and improve their performance. At this point I was going for correctness. \r\n\r\n@losipiuk @pnowojski ","created_at":"2016-02-02T17:27:53Z","updated_at":"2016-02-15T13:28:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"459aa282de371280d8ea69f5c3b24221b0ce926d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/115/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/115/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/115/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/0fd079ed539ed998af4eaa58a23fc918949ba98c","head":{"label":"Teradata:tpch-unmodified","ref":"tpch-unmodified","sha":"0fd079ed539ed998af4eaa58a23fc918949ba98c","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata's Certified Version of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-01-26T12:57:26Z","pushed_at":"2016-02-15T13:28:09Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":90616,"stargazers_count":34,"watchers_count":34,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":13,"forks":5,"open_issues":13,"watchers":34,"default_branch":"master"}},"base":{"label":"Teradata:decimal_v4","ref":"decimal_v4","sha":"d14695078cedda4323a238150100ce38a9e59ed8","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata's Certified Version of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-01-26T12:57:26Z","pushed_at":"2016-02-15T13:28:09Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":90616,"stargazers_count":34,"watchers_count":34,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":13,"forks":5,"open_issues":13,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/115"},"html":{"href":"https://github.com/Teradata/presto/pull/115"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/115"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/115/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/115/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/115/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/0fd079ed539ed998af4eaa58a23fc918949ba98c"}}}}