{"action":"created","comment":{"url":"https://api.github.com/repos/apache/tajo/pulls/comments/28240403","id":28240403,"diff_hunk":"@@ -678,8 +679,26 @@ public EvalNode visitGeneralSetFunction(Context ctx, Stack<Expr> stack, GeneralS\n     }\n   }\n \n+\n   public static final Set<String> WINDOW_FUNCTIONS =\n-      Sets.newHashSet(\"row_number\", \"rank\", \"dense_rank\", \"percent_rank\", \"cume_dist\", \"first_value\", \"lag\");\n+      Sets.newHashSet(\"row_number\", \"rank\", \"dense_rank\", \"percent_rank\", \"cume_dist\", \"ntile\", \"first_value\", \"last_value\", \"lag\");","path":"tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java","position":20,"original_position":20,"commit_id":"35e987046e67fb93e4e2cca577af36c0afc260a1","original_commit_id":"35e987046e67fb93e4e2cca577af36c0afc260a1","user":{"login":"jihoonson","id":2322288,"avatar_url":"https://avatars.githubusercontent.com/u/2322288?v=3","gravatar_id":"","url":"https://api.github.com/users/jihoonson","html_url":"https://github.com/jihoonson","followers_url":"https://api.github.com/users/jihoonson/followers","following_url":"https://api.github.com/users/jihoonson/following{/other_user}","gists_url":"https://api.github.com/users/jihoonson/gists{/gist_id}","starred_url":"https://api.github.com/users/jihoonson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jihoonson/subscriptions","organizations_url":"https://api.github.com/users/jihoonson/orgs","repos_url":"https://api.github.com/users/jihoonson/repos","events_url":"https://api.github.com/users/jihoonson/events{/privacy}","received_events_url":"https://api.github.com/users/jihoonson/received_events","type":"User","site_admin":false},"body":"Right. Thanks.","created_at":"2015-04-13T14:08:36Z","updated_at":"2015-04-13T14:08:36Z","html_url":"https://github.com/apache/tajo/pull/454#discussion_r28240403","pull_request_url":"https://api.github.com/repos/apache/tajo/pulls/454","_links":{"self":{"href":"https://api.github.com/repos/apache/tajo/pulls/comments/28240403"},"html":{"href":"https://github.com/apache/tajo/pull/454#discussion_r28240403"},"pull_request":{"href":"https://api.github.com/repos/apache/tajo/pulls/454"}}},"pull_request":{"url":"https://api.github.com/repos/apache/tajo/pulls/454","id":31712849,"html_url":"https://github.com/apache/tajo/pull/454","diff_url":"https://github.com/apache/tajo/pull/454.diff","patch_url":"https://github.com/apache/tajo/pull/454.patch","issue_url":"https://api.github.com/repos/apache/tajo/issues/454","number":454,"state":"open","locked":false,"title":"TAJO-1415: Window frame support","user":{"login":"sirpkt","id":4968993,"avatar_url":"https://avatars.githubusercontent.com/u/4968993?v=3","gravatar_id":"","url":"https://api.github.com/users/sirpkt","html_url":"https://github.com/sirpkt","followers_url":"https://api.github.com/users/sirpkt/followers","following_url":"https://api.github.com/users/sirpkt/following{/other_user}","gists_url":"https://api.github.com/users/sirpkt/gists{/gist_id}","starred_url":"https://api.github.com/users/sirpkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirpkt/subscriptions","organizations_url":"https://api.github.com/users/sirpkt/orgs","repos_url":"https://api.github.com/users/sirpkt/repos","events_url":"https://api.github.com/users/sirpkt/events{/privacy}","received_events_url":"https://api.github.com/users/sirpkt/received_events","type":"User","site_admin":false},"body":"It supports all ROWS and RANGE window frame.\r\n\r\nCases when window frame is not applied\r\n- no order by clause is used\r\n- some built-in window functions where window frame is not supported: row_number, rank, dense_rank, percent_rank, cume_dist, tile, lag, lead \r\n\r\nCases when window frame should be applied\r\n- other built-in window functions: first_value, last_value, nth_value\r\n- normal aggregation functions\r\n\r\nBased on above information, this patch distinguishes window function types as following three:\r\n 1. built-in window function without window frame support\r\n 2. built-in window function with window frame support\r\n 3. normal aggregation functions used as a window function. In this case, window frame should be supported\r\n\r\nAnd, it further distinguishes window frame types as following four:\r\n 1. entire partition\r\n 2. from the start of the partition to the moving end point relative to current row\r\n 3. from the moving start point relative to current row to the end of the partition\r\n 4. sliding frame as the current row position varies\r\n\r\nCase 1 is the same as previous handling of window function.\r\nCase 2 is handled as incremental termination of aggregation function, which means for every row call merge() and terminate() of the given function\r\nCase 3 is handled almost the same as case 2 except feeding rows to the function from the end of the partition to the start of the frame, i.e., in reverse order\r\nCase 4 is handled by two pass approach: making small loop of feeding rows to the function for each row value computation, I think, which is inevitable since aggregation function does not support sliding window aggregation.\r\n\r\nAll above are implemented for ROWS first, \r\nand then expanded to support RANGE by including rows that has the same order by value with current row in computation of window function.\r\n\r\nThis patch includes following changes\r\n- parser can handle integer offset PRECEDING and FOLLOWING\r\n- ExprAnnotator can reflect window frame information on WindowFunctionEval including default value handling\r\n- WindowAggExec can handles ROWS and RANGE with window frame support\r\n- Parameter checking in parser and ExprAnnotator is included\r\n- last_value is re-implemented as WindowAggFunc. First_value implementation becomes more simple\r\n- Window related classes in tajo-plan has new prefix 'Logical' to distinguish themselves with the same name class in tajo-algebra\r\n- plan.proto is modified to support data structure to distinguish function types and frame types\r\n- add test cases for window frame\r\n","created_at":"2015-03-23T08:39:09Z","updated_at":"2015-04-13T14:08:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"496740506e8e0cf167ae71b5e6a19255a0d57be2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/tajo/pulls/454/commits","review_comments_url":"https://api.github.com/repos/apache/tajo/pulls/454/comments","review_comment_url":"https://api.github.com/repos/apache/tajo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/tajo/issues/454/comments","statuses_url":"https://api.github.com/repos/apache/tajo/statuses/35e987046e67fb93e4e2cca577af36c0afc260a1","head":{"label":"sirpkt:TAJO-1415","ref":"TAJO-1415","sha":"35e987046e67fb93e4e2cca577af36c0afc260a1","user":{"login":"sirpkt","id":4968993,"avatar_url":"https://avatars.githubusercontent.com/u/4968993?v=3","gravatar_id":"","url":"https://api.github.com/users/sirpkt","html_url":"https://github.com/sirpkt","followers_url":"https://api.github.com/users/sirpkt/followers","following_url":"https://api.github.com/users/sirpkt/following{/other_user}","gists_url":"https://api.github.com/users/sirpkt/gists{/gist_id}","starred_url":"https://api.github.com/users/sirpkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirpkt/subscriptions","organizations_url":"https://api.github.com/users/sirpkt/orgs","repos_url":"https://api.github.com/users/sirpkt/repos","events_url":"https://api.github.com/users/sirpkt/events{/privacy}","received_events_url":"https://api.github.com/users/sirpkt/received_events","type":"User","site_admin":false},"repo":{"id":28170489,"name":"tajo","full_name":"sirpkt/tajo","owner":{"login":"sirpkt","id":4968993,"avatar_url":"https://avatars.githubusercontent.com/u/4968993?v=3","gravatar_id":"","url":"https://api.github.com/users/sirpkt","html_url":"https://github.com/sirpkt","followers_url":"https://api.github.com/users/sirpkt/followers","following_url":"https://api.github.com/users/sirpkt/following{/other_user}","gists_url":"https://api.github.com/users/sirpkt/gists{/gist_id}","starred_url":"https://api.github.com/users/sirpkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirpkt/subscriptions","organizations_url":"https://api.github.com/users/sirpkt/orgs","repos_url":"https://api.github.com/users/sirpkt/repos","events_url":"https://api.github.com/users/sirpkt/events{/privacy}","received_events_url":"https://api.github.com/users/sirpkt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sirpkt/tajo","description":"Mirror of Apache Tajo","fork":true,"url":"https://api.github.com/repos/sirpkt/tajo","forks_url":"https://api.github.com/repos/sirpkt/tajo/forks","keys_url":"https://api.github.com/repos/sirpkt/tajo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sirpkt/tajo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sirpkt/tajo/teams","hooks_url":"https://api.github.com/repos/sirpkt/tajo/hooks","issue_events_url":"https://api.github.com/repos/sirpkt/tajo/issues/events{/number}","events_url":"https://api.github.com/repos/sirpkt/tajo/events","assignees_url":"https://api.github.com/repos/sirpkt/tajo/assignees{/user}","branches_url":"https://api.github.com/repos/sirpkt/tajo/branches{/branch}","tags_url":"https://api.github.com/repos/sirpkt/tajo/tags","blobs_url":"https://api.github.com/repos/sirpkt/tajo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sirpkt/tajo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sirpkt/tajo/git/refs{/sha}","trees_url":"https://api.github.com/repos/sirpkt/tajo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sirpkt/tajo/statuses/{sha}","languages_url":"https://api.github.com/repos/sirpkt/tajo/languages","stargazers_url":"https://api.github.com/repos/sirpkt/tajo/stargazers","contributors_url":"https://api.github.com/repos/sirpkt/tajo/contributors","subscribers_url":"https://api.github.com/repos/sirpkt/tajo/subscribers","subscription_url":"https://api.github.com/repos/sirpkt/tajo/subscription","commits_url":"https://api.github.com/repos/sirpkt/tajo/commits{/sha}","git_commits_url":"https://api.github.com/repos/sirpkt/tajo/git/commits{/sha}","comments_url":"https://api.github.com/repos/sirpkt/tajo/comments{/number}","issue_comment_url":"https://api.github.com/repos/sirpkt/tajo/issues/comments{/number}","contents_url":"https://api.github.com/repos/sirpkt/tajo/contents/{+path}","compare_url":"https://api.github.com/repos/sirpkt/tajo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sirpkt/tajo/merges","archive_url":"https://api.github.com/repos/sirpkt/tajo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sirpkt/tajo/downloads","issues_url":"https://api.github.com/repos/sirpkt/tajo/issues{/number}","pulls_url":"https://api.github.com/repos/sirpkt/tajo/pulls{/number}","milestones_url":"https://api.github.com/repos/sirpkt/tajo/milestones{/number}","notifications_url":"https://api.github.com/repos/sirpkt/tajo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sirpkt/tajo/labels{/name}","releases_url":"https://api.github.com/repos/sirpkt/tajo/releases{/id}","created_at":"2014-12-18T05:58:47Z","updated_at":"2015-04-13T10:58:02Z","pushed_at":"2015-04-13T10:58:00Z","git_url":"git://github.com/sirpkt/tajo.git","ssh_url":"git@github.com:sirpkt/tajo.git","clone_url":"https://github.com/sirpkt/tajo.git","svn_url":"https://github.com/sirpkt/tajo","homepage":null,"size":16396,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"72948b63a79cd8902381c3443699c887b2740491","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17971138,"name":"tajo","full_name":"apache/tajo","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/tajo","description":"Mirror of Apache Tajo","fork":false,"url":"https://api.github.com/repos/apache/tajo","forks_url":"https://api.github.com/repos/apache/tajo/forks","keys_url":"https://api.github.com/repos/apache/tajo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/tajo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/tajo/teams","hooks_url":"https://api.github.com/repos/apache/tajo/hooks","issue_events_url":"https://api.github.com/repos/apache/tajo/issues/events{/number}","events_url":"https://api.github.com/repos/apache/tajo/events","assignees_url":"https://api.github.com/repos/apache/tajo/assignees{/user}","branches_url":"https://api.github.com/repos/apache/tajo/branches{/branch}","tags_url":"https://api.github.com/repos/apache/tajo/tags","blobs_url":"https://api.github.com/repos/apache/tajo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/tajo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/tajo/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/tajo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/tajo/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/tajo/languages","stargazers_url":"https://api.github.com/repos/apache/tajo/stargazers","contributors_url":"https://api.github.com/repos/apache/tajo/contributors","subscribers_url":"https://api.github.com/repos/apache/tajo/subscribers","subscription_url":"https://api.github.com/repos/apache/tajo/subscription","commits_url":"https://api.github.com/repos/apache/tajo/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/tajo/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/tajo/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/tajo/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/tajo/contents/{+path}","compare_url":"https://api.github.com/repos/apache/tajo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/tajo/merges","archive_url":"https://api.github.com/repos/apache/tajo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/tajo/downloads","issues_url":"https://api.github.com/repos/apache/tajo/issues{/number}","pulls_url":"https://api.github.com/repos/apache/tajo/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/tajo/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/tajo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/tajo/labels{/name}","releases_url":"https://api.github.com/repos/apache/tajo/releases{/id}","created_at":"2014-03-21T07:00:07Z","updated_at":"2015-04-13T13:50:46Z","pushed_at":"2015-04-13T13:50:46Z","git_url":"git://github.com/apache/tajo.git","ssh_url":"git@github.com:apache/tajo.git","clone_url":"https://github.com/apache/tajo.git","svn_url":"https://github.com/apache/tajo","homepage":null,"size":38760,"stargazers_count":45,"watchers_count":45,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":58,"mirror_url":"git://git.apache.org/tajo.git","open_issues_count":65,"forks":58,"open_issues":65,"watchers":45,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/tajo/pulls/454"},"html":{"href":"https://github.com/apache/tajo/pull/454"},"issue":{"href":"https://api.github.com/repos/apache/tajo/issues/454"},"comments":{"href":"https://api.github.com/repos/apache/tajo/issues/454/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/tajo/pulls/454/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/tajo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/tajo/pulls/454/commits"},"statuses":{"href":"https://api.github.com/repos/apache/tajo/statuses/35e987046e67fb93e4e2cca577af36c0afc260a1"}}}}