{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/76493362","id":76493362,"diff_hunk":"@@ -24,20 +26,83 @@\n \n import java.util.LinkedList;\n import java.util.List;\n+import java.util.Map;\n import java.util.stream.Collectors;\n \n import static java.util.Objects.requireNonNull;\n \n final class WindowMatcher\n         implements Matcher\n {\n+    private final WindowNode.Specification specification;\n     private final List<FunctionCall> functionCalls;\n \n-    WindowMatcher(List<FunctionCall> functionCalls)\n+    WindowMatcher(WindowNode.Specification specification, List<FunctionCall> functionCalls)\n     {\n+        this.specification = specification;\n         this.functionCalls = ImmutableList.copyOf(requireNonNull(functionCalls, \"functionCalls is null\"));\n     }\n \n+    private static boolean sameIshSpecification(\n+            WindowNode.Specification expected,\n+            WindowNode.Specification actual)\n+    {\n+        if (!expected.getPartitionBy().equals(actual.getPartitionBy()) ||\n+                !expected.getOrderBy().equals(actual.getOrderBy())) {\n+            return false;\n+        }\n+\n+        Map<Symbol, SortOrder> expectedOrderings = expected.getOrderings();\n+        Map<Symbol, SortOrder> actualOrderings = actual.getOrderings();\n+\n+        if (expectedOrderings.size() != actualOrderings.size()) {\n+            return false;\n+        }\n+\n+        /*\n+         * Ooof. Sad story time.\n+         *\n+         * Symbols in the plan get decorated with a number if the same symbol is used twice. E.g. if two parts\n+         * of a query both refer to a column foo, you'll end up with symbols foo and foo_32 (for example).\n+         *\n+         * When we verify the orderings in a plan, the orderings take the form of a Map<Symbol, SortOrder>.\n+         * Unfortunately, we have no way of knowing a priori what the number affixed to the symbol name, and\n+         * even if we did, we'd be relying on implementation details of the SymbolAllocator.\n+         *\n+         * What's further unfortunate is that we can't just extend Symbol with something that compares equal\n+         * to a Symbol with a name that has a unique id affixed. This is because we end up going through\n+         * Map.equals, and if you dig deep enough you end up finding that the hashCodes would have to match too.\n+         * Since we can't change how Symbol.hashCode is implemented (and wouldn't want to!), we're back to\n+         * needing to know the unknowable.\n+         *\n+         * Another approach to making to WindowNode.Specifications compare with .equals() that doesn't work\n+         * is extending Map to do the comparison in a way that doesn't rely on hashCode. That doesn't work\n+         * because WindowNode.Specification copies the members of the map you pass to its constructor.\n+         *\n+         * Instead, we implement the comparison here in a way that doesn't rely on hashCode. This is brittle\n+         * because if somebody adds another field to Specification that's included in a equals comparison,\n+         * this need to be updated too.\n+         */\n+        actualEntries:","path":"presto-main/src/test/java/com/facebook/presto/sql/planner/assertions/WindowMatcher.java","position":71,"original_position":71,"commit_id":"68f3f2170cf7f3929cc1424129e742f075cce95d","original_commit_id":"a4576394650a8a870a9ad9fd7743d5d3017ea013","user":{"login":"maciejgrzybek","id":366501,"avatar_url":"https://avatars.githubusercontent.com/u/366501?v=3","gravatar_id":"","url":"https://api.github.com/users/maciejgrzybek","html_url":"https://github.com/maciejgrzybek","followers_url":"https://api.github.com/users/maciejgrzybek/followers","following_url":"https://api.github.com/users/maciejgrzybek/following{/other_user}","gists_url":"https://api.github.com/users/maciejgrzybek/gists{/gist_id}","starred_url":"https://api.github.com/users/maciejgrzybek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciejgrzybek/subscriptions","organizations_url":"https://api.github.com/users/maciejgrzybek/orgs","repos_url":"https://api.github.com/users/maciejgrzybek/repos","events_url":"https://api.github.com/users/maciejgrzybek/events{/privacy}","received_events_url":"https://api.github.com/users/maciejgrzybek/received_events","type":"User","site_admin":false},"body":"What a gross...\r\nWouldn't it look better if you copied both entry-sets each to a separate List, sort both and compare elements one by one?","created_at":"2016-08-26T21:48:40Z","updated_at":"2016-08-26T21:48:40Z","html_url":"https://github.com/Teradata/presto/pull/326#discussion_r76493362","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/326","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/76493362"},"html":{"href":"https://github.com/Teradata/presto/pull/326#discussion_r76493362"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/326"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/326","id":82949650,"html_url":"https://github.com/Teradata/presto/pull/326","diff_url":"https://github.com/Teradata/presto/pull/326.diff","patch_url":"https://github.com/Teradata/presto/pull/326.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/326","number":326,"state":"open","locked":false,"title":"Window matcher rework","user":{"login":"ebd2","id":12751788,"avatar_url":"https://avatars.githubusercontent.com/u/12751788?v=3","gravatar_id":"","url":"https://api.github.com/users/ebd2","html_url":"https://github.com/ebd2","followers_url":"https://api.github.com/users/ebd2/followers","following_url":"https://api.github.com/users/ebd2/following{/other_user}","gists_url":"https://api.github.com/users/ebd2/gists{/gist_id}","starred_url":"https://api.github.com/users/ebd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebd2/subscriptions","organizations_url":"https://api.github.com/users/ebd2/orgs","repos_url":"https://api.github.com/users/ebd2/repos","events_url":"https://api.github.com/users/ebd2/events{/privacy}","received_events_url":"https://api.github.com/users/ebd2/received_events","type":"User","site_admin":false},"body":"The FunctionCalls in WindowNodes come directly from the AST, and are not filled\r\nin with defaults when the user omits e.g. the orderings in a query. The DSL for\r\nthe unit tests should verify as much information about the window from the plan\r\nand only the function calls and their associated frame information in the AST.\r\n\r\n\r\n@maciejgrzybek ","created_at":"2016-08-26T20:30:46Z","updated_at":"2016-08-26T21:48:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4e2e0f735549ddf8f9f6db9c4a7427f14645196","assignee":{"login":"maciejgrzybek","id":366501,"avatar_url":"https://avatars.githubusercontent.com/u/366501?v=3","gravatar_id":"","url":"https://api.github.com/users/maciejgrzybek","html_url":"https://github.com/maciejgrzybek","followers_url":"https://api.github.com/users/maciejgrzybek/followers","following_url":"https://api.github.com/users/maciejgrzybek/following{/other_user}","gists_url":"https://api.github.com/users/maciejgrzybek/gists{/gist_id}","starred_url":"https://api.github.com/users/maciejgrzybek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciejgrzybek/subscriptions","organizations_url":"https://api.github.com/users/maciejgrzybek/orgs","repos_url":"https://api.github.com/users/maciejgrzybek/repos","events_url":"https://api.github.com/users/maciejgrzybek/events{/privacy}","received_events_url":"https://api.github.com/users/maciejgrzybek/received_events","type":"User","site_admin":false},"assignees":[{"login":"maciejgrzybek","id":366501,"avatar_url":"https://avatars.githubusercontent.com/u/366501?v=3","gravatar_id":"","url":"https://api.github.com/users/maciejgrzybek","html_url":"https://github.com/maciejgrzybek","followers_url":"https://api.github.com/users/maciejgrzybek/followers","following_url":"https://api.github.com/users/maciejgrzybek/following{/other_user}","gists_url":"https://api.github.com/users/maciejgrzybek/gists{/gist_id}","starred_url":"https://api.github.com/users/maciejgrzybek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciejgrzybek/subscriptions","organizations_url":"https://api.github.com/users/maciejgrzybek/orgs","repos_url":"https://api.github.com/users/maciejgrzybek/repos","events_url":"https://api.github.com/users/maciejgrzybek/events{/privacy}","received_events_url":"https://api.github.com/users/maciejgrzybek/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/326/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/326/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/326/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/68f3f2170cf7f3929cc1424129e742f075cce95d","head":{"label":"Teradata:window-matcher-rework","ref":"window-matcher-rework","sha":"68f3f2170cf7f3929cc1424129e742f075cce95d","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 Distribution 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-08-26T18:39:42Z","pushed_at":"2016-08-26T21:39: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":155937,"stargazers_count":54,"watchers_count":54,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":22,"forks":10,"open_issues":22,"watchers":54,"default_branch":"master"}},"base":{"label":"Teradata:window_refactor/2","ref":"window_refactor/2","sha":"657a2f2ab6d0ad718c18b460fe39b3ab556dfdbc","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 Distribution 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-08-26T18:39:42Z","pushed_at":"2016-08-26T21:39: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":155937,"stargazers_count":54,"watchers_count":54,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":22,"forks":10,"open_issues":22,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/326"},"html":{"href":"https://github.com/Teradata/presto/pull/326"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/326"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/326/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/326/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/68f3f2170cf7f3929cc1424129e742f075cce95d"}}}}
{"actor":{"display_login":"maciejgrzybek"}}