{"action":"created","comment":{"url":"https://api.github.com/repos/prestodb/presto/pulls/comments/172322368","pull_request_review_id":101306055,"id":172322368,"diff_hunk":"@@ -96,19 +110,53 @@ public static Block sequenceTimestampYearToMonth(\n         return blockBuilder.build();\n     }\n \n+    @ScalarFunction(\"sequence\")\n+    @SqlType(\"array(date)\")\n+    public static Block sequenceTimestampYearToMonthForDate(\n+            ConnectorSession session,\n+            @SqlType(StandardTypes.DATE) long start,\n+            @SqlType(StandardTypes.DATE) long stop,\n+            @SqlType(StandardTypes.INTERVAL_YEAR_TO_MONTH) long step)\n+    {\n+        checkCommonInvalidConditions(start, stop, step);\n+\n+        int length = toIntExact(diffDate(session, MONTH, start, stop) / step + 1);\n+        checkMaxEntryCondition(length);\n+\n+        BlockBuilder blockBuilder = DATE.createBlockBuilder(new BlockBuilderStatus(), length);\n+\n+        int value = 0;\n+        for (int i = 0; i < length; ++i) {\n+            DATE.writeLong(blockBuilder, DateTimeOperators.datePlusIntervalYearToMonth(start, value));\n+            value += step;\n+        }\n+\n+        return blockBuilder.build();\n+    }\n+\n     private static Block fixedWidthSequence(long start, long stop, long step, FixedWidthType type)\n     {\n-        checkCondition(step != 0, INVALID_FUNCTION_ARGUMENT, \"step must not be zero\");\n-        checkCondition(step > 0 ? stop >= start : stop < start, INVALID_FUNCTION_ARGUMENT,\n-                \"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start\");\n+        checkCommonInvalidConditions(start, stop, step);\n \n         int length = toIntExact((stop - start) / step + 1L);\n-        checkCondition(length <= MAX_RESULT_ENTRIES, INVALID_FUNCTION_ARGUMENT, \"result of sequence function must not have more than 10000 entries\");\n+        checkMaxEntryCondition(length);\n \n         BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), length);\n         for (long i = 0, value = start; i < length; ++i, value += step) {\n             type.writeLong(blockBuilder, value);\n         }\n         return blockBuilder.build();\n     }\n+\n+    private static void checkCommonInvalidConditions(long start, long stop, long step)\n+    {\n+        checkCondition(step != 0, INVALID_FUNCTION_ARGUMENT, \"step must not be zero\");\n+        checkCondition(step > 0 ? stop >= start : stop < start, INVALID_FUNCTION_ARGUMENT,","path":"presto-main/src/main/java/com/facebook/presto/operator/scalar/SequenceFunction.java","position":100,"original_position":100,"commit_id":"37e34a94a3a5e403b81e4fabfaf124c5f7834d52","original_commit_id":"37e34a94a3a5e403b81e4fabfaf124c5f7834d52","user":{"login":"haozhun","id":2020503,"avatar_url":"https://avatars3.githubusercontent.com/u/2020503?v=4","gravatar_id":"","url":"https://api.github.com/users/haozhun","html_url":"https://github.com/haozhun","followers_url":"https://api.github.com/users/haozhun/followers","following_url":"https://api.github.com/users/haozhun/following{/other_user}","gists_url":"https://api.github.com/users/haozhun/gists{/gist_id}","starred_url":"https://api.github.com/users/haozhun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haozhun/subscriptions","organizations_url":"https://api.github.com/users/haozhun/orgs","repos_url":"https://api.github.com/users/haozhun/repos","events_url":"https://api.github.com/users/haozhun/events{/privacy}","received_events_url":"https://api.github.com/users/haozhun/received_events","type":"User","site_admin":false},"body":"The original formatting is not consistent with the preferred style. Write it as\r\n\r\n```\r\ncheckCondition(\r\n        step > 0 ? stop >= start : stop < start,\r\n        INVALID_FUNCTION_ARGUMENT,\r\n        \"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start\");\r\n```\r\n\r\nWe prefer putting each argument (including the first one) on its own line.","created_at":"2018-03-05T20:45:03Z","updated_at":"2018-03-05T21:03:47Z","html_url":"https://github.com/prestodb/presto/pull/10077#discussion_r172322368","pull_request_url":"https://api.github.com/repos/prestodb/presto/pulls/10077","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments/172322368"},"html":{"href":"https://github.com/prestodb/presto/pull/10077#discussion_r172322368"},"pull_request":{"href":"https://api.github.com/repos/prestodb/presto/pulls/10077"}}},"pull_request":{"url":"https://api.github.com/repos/prestodb/presto/pulls/10077","id":172611721,"html_url":"https://github.com/prestodb/presto/pull/10077","diff_url":"https://github.com/prestodb/presto/pull/10077.diff","patch_url":"https://github.com/prestodb/presto/pull/10077.patch","issue_url":"https://api.github.com/repos/prestodb/presto/issues/10077","number":10077,"state":"open","locked":false,"title":"Add sequence variant for DATE","user":{"login":"ngqtien","id":36937667,"avatar_url":"https://avatars2.githubusercontent.com/u/36937667?v=4","gravatar_id":"","url":"https://api.github.com/users/ngqtien","html_url":"https://github.com/ngqtien","followers_url":"https://api.github.com/users/ngqtien/followers","following_url":"https://api.github.com/users/ngqtien/following{/other_user}","gists_url":"https://api.github.com/users/ngqtien/gists{/gist_id}","starred_url":"https://api.github.com/users/ngqtien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngqtien/subscriptions","organizations_url":"https://api.github.com/users/ngqtien/orgs","repos_url":"https://api.github.com/users/ngqtien/repos","events_url":"https://api.github.com/users/ngqtien/events{/privacy}","received_events_url":"https://api.github.com/users/ngqtien/received_events","type":"User","site_admin":false},"body":"As mentioned at issue https://github.com/prestodb/presto/issues/9681, the current return type for `SEQUENCE` function is `TIMESTAMP`, but we want to support `DATE` as well when we're using date type for start and stop arguments.","created_at":"2018-03-02T21:41:56Z","updated_at":"2018-03-05T21:03:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"649f769966d0e62a4401f5e98f58bff6aa916dad","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":196992743,"url":"https://api.github.com/repos/prestodb/presto/labels/CLA%20Signed","name":"CLA Signed","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/prestodb/presto/pulls/10077/commits","review_comments_url":"https://api.github.com/repos/prestodb/presto/pulls/10077/comments","review_comment_url":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/10077/comments","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/37e34a94a3a5e403b81e4fabfaf124c5f7834d52","head":{"label":"ngqtien:fix-issue-9681","ref":"fix-issue-9681","sha":"37e34a94a3a5e403b81e4fabfaf124c5f7834d52","user":{"login":"ngqtien","id":36937667,"avatar_url":"https://avatars2.githubusercontent.com/u/36937667?v=4","gravatar_id":"","url":"https://api.github.com/users/ngqtien","html_url":"https://github.com/ngqtien","followers_url":"https://api.github.com/users/ngqtien/followers","following_url":"https://api.github.com/users/ngqtien/following{/other_user}","gists_url":"https://api.github.com/users/ngqtien/gists{/gist_id}","starred_url":"https://api.github.com/users/ngqtien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngqtien/subscriptions","organizations_url":"https://api.github.com/users/ngqtien/orgs","repos_url":"https://api.github.com/users/ngqtien/repos","events_url":"https://api.github.com/users/ngqtien/events{/privacy}","received_events_url":"https://api.github.com/users/ngqtien/received_events","type":"User","site_admin":false},"repo":{"id":123358135,"name":"presto","full_name":"ngqtien/presto","owner":{"login":"ngqtien","id":36937667,"avatar_url":"https://avatars2.githubusercontent.com/u/36937667?v=4","gravatar_id":"","url":"https://api.github.com/users/ngqtien","html_url":"https://github.com/ngqtien","followers_url":"https://api.github.com/users/ngqtien/followers","following_url":"https://api.github.com/users/ngqtien/following{/other_user}","gists_url":"https://api.github.com/users/ngqtien/gists{/gist_id}","starred_url":"https://api.github.com/users/ngqtien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngqtien/subscriptions","organizations_url":"https://api.github.com/users/ngqtien/orgs","repos_url":"https://api.github.com/users/ngqtien/repos","events_url":"https://api.github.com/users/ngqtien/events{/privacy}","received_events_url":"https://api.github.com/users/ngqtien/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ngqtien/presto","description":"Distributed SQL query engine for big data","fork":true,"url":"https://api.github.com/repos/ngqtien/presto","forks_url":"https://api.github.com/repos/ngqtien/presto/forks","keys_url":"https://api.github.com/repos/ngqtien/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ngqtien/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ngqtien/presto/teams","hooks_url":"https://api.github.com/repos/ngqtien/presto/hooks","issue_events_url":"https://api.github.com/repos/ngqtien/presto/issues/events{/number}","events_url":"https://api.github.com/repos/ngqtien/presto/events","assignees_url":"https://api.github.com/repos/ngqtien/presto/assignees{/user}","branches_url":"https://api.github.com/repos/ngqtien/presto/branches{/branch}","tags_url":"https://api.github.com/repos/ngqtien/presto/tags","blobs_url":"https://api.github.com/repos/ngqtien/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ngqtien/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ngqtien/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/ngqtien/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ngqtien/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/ngqtien/presto/languages","stargazers_url":"https://api.github.com/repos/ngqtien/presto/stargazers","contributors_url":"https://api.github.com/repos/ngqtien/presto/contributors","subscribers_url":"https://api.github.com/repos/ngqtien/presto/subscribers","subscription_url":"https://api.github.com/repos/ngqtien/presto/subscription","commits_url":"https://api.github.com/repos/ngqtien/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/ngqtien/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/ngqtien/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/ngqtien/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/ngqtien/presto/contents/{+path}","compare_url":"https://api.github.com/repos/ngqtien/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ngqtien/presto/merges","archive_url":"https://api.github.com/repos/ngqtien/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ngqtien/presto/downloads","issues_url":"https://api.github.com/repos/ngqtien/presto/issues{/number}","pulls_url":"https://api.github.com/repos/ngqtien/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/ngqtien/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/ngqtien/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ngqtien/presto/labels{/name}","releases_url":"https://api.github.com/repos/ngqtien/presto/releases{/id}","deployments_url":"https://api.github.com/repos/ngqtien/presto/deployments","created_at":"2018-03-01T00:10:42Z","updated_at":"2018-03-01T00:11:00Z","pushed_at":"2018-03-02T21:39:27Z","git_url":"git://github.com/ngqtien/presto.git","ssh_url":"git@github.com:ngqtien/presto.git","clone_url":"https://github.com/ngqtien/presto.git","svn_url":"https://github.com/ngqtien/presto","homepage":"https://prestodb.io","size":87662,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prestodb:master","ref":"master","sha":"81b704de641a42cf38552f035fcefe3d652c3e01","user":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars0.githubusercontent.com/u/6882181?v=4","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"repo":{"id":5349565,"name":"presto","full_name":"prestodb/presto","owner":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars0.githubusercontent.com/u/6882181?v=4","gravatar_id":"","url":"https://api.github.com/users/prestodb","html_url":"https://github.com/prestodb","followers_url":"https://api.github.com/users/prestodb/followers","following_url":"https://api.github.com/users/prestodb/following{/other_user}","gists_url":"https://api.github.com/users/prestodb/gists{/gist_id}","starred_url":"https://api.github.com/users/prestodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prestodb/subscriptions","organizations_url":"https://api.github.com/users/prestodb/orgs","repos_url":"https://api.github.com/users/prestodb/repos","events_url":"https://api.github.com/users/prestodb/events{/privacy}","received_events_url":"https://api.github.com/users/prestodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prestodb/presto","description":"Distributed SQL query engine for big data","fork":false,"url":"https://api.github.com/repos/prestodb/presto","forks_url":"https://api.github.com/repos/prestodb/presto/forks","keys_url":"https://api.github.com/repos/prestodb/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prestodb/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prestodb/presto/teams","hooks_url":"https://api.github.com/repos/prestodb/presto/hooks","issue_events_url":"https://api.github.com/repos/prestodb/presto/issues/events{/number}","events_url":"https://api.github.com/repos/prestodb/presto/events","assignees_url":"https://api.github.com/repos/prestodb/presto/assignees{/user}","branches_url":"https://api.github.com/repos/prestodb/presto/branches{/branch}","tags_url":"https://api.github.com/repos/prestodb/presto/tags","blobs_url":"https://api.github.com/repos/prestodb/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prestodb/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prestodb/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/prestodb/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/prestodb/presto/languages","stargazers_url":"https://api.github.com/repos/prestodb/presto/stargazers","contributors_url":"https://api.github.com/repos/prestodb/presto/contributors","subscribers_url":"https://api.github.com/repos/prestodb/presto/subscribers","subscription_url":"https://api.github.com/repos/prestodb/presto/subscription","commits_url":"https://api.github.com/repos/prestodb/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/prestodb/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/prestodb/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/prestodb/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/prestodb/presto/contents/{+path}","compare_url":"https://api.github.com/repos/prestodb/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prestodb/presto/merges","archive_url":"https://api.github.com/repos/prestodb/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prestodb/presto/downloads","issues_url":"https://api.github.com/repos/prestodb/presto/issues{/number}","pulls_url":"https://api.github.com/repos/prestodb/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/prestodb/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/prestodb/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prestodb/presto/labels{/name}","releases_url":"https://api.github.com/repos/prestodb/presto/releases{/id}","deployments_url":"https://api.github.com/repos/prestodb/presto/deployments","created_at":"2012-08-09T01:03:37Z","updated_at":"2018-03-05T13:38:38Z","pushed_at":"2018-03-05T20:56:53Z","git_url":"git://github.com/prestodb/presto.git","ssh_url":"git@github.com:prestodb/presto.git","clone_url":"https://github.com/prestodb/presto.git","svn_url":"https://github.com/prestodb/presto","homepage":"https://prestodb.io","size":88050,"stargazers_count":7172,"watchers_count":7172,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2395,"mirror_url":null,"archived":false,"open_issues_count":1211,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2395,"open_issues":1211,"watchers":7172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/10077"},"html":{"href":"https://github.com/prestodb/presto/pull/10077"},"issue":{"href":"https://api.github.com/repos/prestodb/presto/issues/10077"},"comments":{"href":"https://api.github.com/repos/prestodb/presto/issues/10077/comments"},"review_comments":{"href":"https://api.github.com/repos/prestodb/presto/pulls/10077/comments"},"review_comment":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prestodb/presto/pulls/10077/commits"},"statuses":{"href":"https://api.github.com/repos/prestodb/presto/statuses/37e34a94a3a5e403b81e4fabfaf124c5f7834d52"}},"author_association":"NONE"}}
{"actor":{"display_login":"haozhun"}}