{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/62274867","id":62274867,"diff_hunk":"@@ -0,0 +1,111 @@\n+/* This file is part of VoltDB.\n+ * Copyright (C) 2008-2016 VoltDB Inc.\n+ *\n+ * This file contains original code and/or modifications of original code.\n+ * Any modifications made by VoltDB Inc. are licensed under the following\n+ * terms and conditions:\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining\n+ * a copy of this software and associated documentation files (the\n+ * \"Software\"), to deal in the Software without restriction, including\n+ * without limitation the rights to use, copy, modify, merge, publish,\n+ * distribute, sublicense, and/or sell copies of the Software, and to\n+ * permit persons to whom the Software is furnished to do so, subject to\n+ * the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be\n+ * included in all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n+ * OTHER DEALINGS IN THE SOFTWARE.\n+ */\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements. See the NOTICE file distributed with this\n+ * work for additional information regarding copyright ownership. The ASF\n+ * licenses this file to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */package org.voltdb.planner;\n+\n+import org.voltdb.expressions.WindowedExpression;\n+import org.voltdb.plannodes.AbstractPlanNode;\n+import org.voltdb.plannodes.NestLoopPlanNode;\n+import org.voltdb.plannodes.NodeSchema;\n+import org.voltdb.plannodes.OrderByPlanNode;\n+import org.voltdb.plannodes.PartitionByPlanNode;\n+import org.voltdb.plannodes.SchemaColumn;\n+import org.voltdb.plannodes.SendPlanNode;\n+import org.voltdb.plannodes.SeqScanPlanNode;\n+\n+public class TestWindowingFunctions extends PlannerTestCase {\n+    public void testRank() {\n+        AbstractPlanNode node = compile(\"SELECT B, RANK() OVER (PARTITION BY A,B ORDER BY B ) AS ARANK FROM AAA;\");\n+        // The plan should look like:\n+        // SendNode -> PartitionByPlanNode -> OrderByPlanNode -> SeqScanNode\n+        // We also do some santity checking on the PartitionPlan node.\n+        assertTrue(node instanceof SendPlanNode);\n+        AbstractPlanNode abstractPBPlanNode = node.getChild(0);\n+        assertTrue(abstractPBPlanNode instanceof PartitionByPlanNode);\n+        PartitionByPlanNode pbPlanNode = (PartitionByPlanNode)abstractPBPlanNode;\n+        NodeSchema  schema = pbPlanNode.getOutputSchema();\n+        assertEquals(2, schema.getColumns().size());\n+        SchemaColumn column = schema.getColumns().get(1);\n+        assertTrue(column.getExpression() instanceof WindowedExpression);\n+        assertEquals(\"ARANK\", column.getColumnAlias());\n+        AbstractPlanNode OBNode = abstractPBPlanNode.getChild(0);\n+        assertTrue(OBNode instanceof OrderByPlanNode);\n+        AbstractPlanNode SScanNode = OBNode.getChild(0);\n+        assertTrue(SScanNode instanceof SeqScanPlanNode);\n+    }\n+\n+    public void testRankWithSubqueries() {\n+        AbstractPlanNode node = compile(\"SELECT BBB.B, RANK() OVER (PARTITION BY A ORDER BY B ) AS ARANK FROM (select A, B, C from AAA where A < B) ALPHA, BBB WHERE ALPHA.C <> BBB.C;\");\n+        assertTrue(node instanceof SendPlanNode);\n+        AbstractPlanNode abstractPBPlanNode = node.getChild(0);\n+        assertTrue(abstractPBPlanNode instanceof PartitionByPlanNode);\n+        PartitionByPlanNode pbPlanNode = (PartitionByPlanNode)abstractPBPlanNode;\n+        NodeSchema  schema = pbPlanNode.getOutputSchema();\n+        assertEquals(2, schema.getColumns().size());\n+        SchemaColumn column = schema.getColumns().get(1);\n+        assertTrue(column.getExpression() instanceof WindowedExpression);\n+        assertEquals(\"ARANK\", column.getColumnAlias());\n+        AbstractPlanNode OBNode = abstractPBPlanNode.getChild(0);\n+        assertTrue(OBNode instanceof OrderByPlanNode);\n+        AbstractPlanNode abstractSScanNode = OBNode.getChild(0);\n+        assertTrue(abstractSScanNode instanceof NestLoopPlanNode);\n+    }\n+\n+    public void testRankFailures() {\n+        failToCompile(\"SELECT RANK() OVER (PARTITION BY A ORDER BY B ) FROM AAA GROUP BY A;\",\n+                      \"windowed operations are not allowed in the same query as an ORDER BY.\");","path":"tests/frontend/org/voltdb/planner/TestWindowingFunctions.java","position":94,"original_position":94,"commit_id":"765ad5b4b355398e5308215156156bf58069b62b","original_commit_id":"765ad5b4b355398e5308215156156bf58069b62b","user":{"login":"wolffcm","id":7902964,"avatar_url":"https://avatars.githubusercontent.com/u/7902964?v=3","gravatar_id":"","url":"https://api.github.com/users/wolffcm","html_url":"https://github.com/wolffcm","followers_url":"https://api.github.com/users/wolffcm/followers","following_url":"https://api.github.com/users/wolffcm/following{/other_user}","gists_url":"https://api.github.com/users/wolffcm/gists{/gist_id}","starred_url":"https://api.github.com/users/wolffcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolffcm/subscriptions","organizations_url":"https://api.github.com/users/wolffcm/orgs","repos_url":"https://api.github.com/users/wolffcm/repos","events_url":"https://api.github.com/users/wolffcm/events{/privacy}","received_events_url":"https://api.github.com/users/wolffcm/received_events","type":"User","site_admin":false},"body":"And I would think that using a windowed expression and a trailing ORDER BY that applies to the output of the SELECT statement *is* supported?","created_at":"2016-05-06T00:12:19Z","updated_at":"2016-05-06T00:12:19Z","html_url":"https://github.com/VoltDB/voltdb/pull/3547#discussion_r62274867","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/62274867"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3547#discussion_r62274867"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547","id":68885810,"html_url":"https://github.com/VoltDB/voltdb/pull/3547","diff_url":"https://github.com/VoltDB/voltdb/pull/3547.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/3547.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3547","number":3547,"state":"open","locked":false,"title":"Planner support for PartitionByPlanNode and Windowed Rank","user":{"login":"BillWhite","id":924098,"avatar_url":"https://avatars.githubusercontent.com/u/924098?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWhite","html_url":"https://github.com/BillWhite","followers_url":"https://api.github.com/users/BillWhite/followers","following_url":"https://api.github.com/users/BillWhite/following{/other_user}","gists_url":"https://api.github.com/users/BillWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWhite/subscriptions","organizations_url":"https://api.github.com/users/BillWhite/orgs","repos_url":"https://api.github.com/users/BillWhite/repos","events_url":"https://api.github.com/users/BillWhite/events{/privacy}","received_events_url":"https://api.github.com/users/BillWhite/received_events","type":"User","site_admin":false},"body":"This commit adds planner support for PartitionByPlanNode and for the\r\nwindowed rank function.  This is the slow path implementation, not the\r\nfast path implementation of Xin's Innovation Week project.\r\n\r\nWe create a PartitionByPlanNode preceded by an OrderByPlanNode.  The\r\nwindowed rank expression is kept in the display list.  The\r\nOrderByPlanNode sorts on the partition by columns, and then by the order\r\nby columns in the windowed rank expression.\r\n\r\nThere are tests for the unsupported case of having more than one rank\r\nand for having a rank with a group by.  There are tests for the\r\nsupported case of an ordinary windowed rank function and for having a\r\nrank computed over a subquery.\r\n\r\nI should add that Jenkins is not all blue on this, but it's very close.  The\r\nremaining failures either pass when run manually, or else they are failing\r\nalready on master.\r\n","created_at":"2016-05-04T15:50:39Z","updated_at":"2016-05-06T00:12:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9b342ecc404656f0d1e098441d81fa7ab869879","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/3547/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/765ad5b4b355398e5308215156156bf58069b62b","head":{"label":"VoltDB:ENG-10033-PBPlannerSupport","ref":"ENG-10033-PBPlannerSupport","sha":"765ad5b4b355398e5308215156156bf58069b62b","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-05-05T21:22:12Z","pushed_at":"2016-05-06T00:04:01Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":626994,"stargazers_count":767,"watchers_count":767,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":235,"mirror_url":null,"open_issues_count":32,"forks":235,"open_issues":32,"watchers":767,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"70475ce7e59ba15dd49563f80ee927cb6eed1840","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","deployments_url":"https://api.github.com/repos/VoltDB/voltdb/deployments","created_at":"2011-09-23T18:46:12Z","updated_at":"2016-05-05T21:22:12Z","pushed_at":"2016-05-06T00:04:01Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":626994,"stargazers_count":767,"watchers_count":767,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":235,"mirror_url":null,"open_issues_count":32,"forks":235,"open_issues":32,"watchers":767,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/3547"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3547"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/3547/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/3547/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/765ad5b4b355398e5308215156156bf58069b62b"}}}}