{"action":"created","comment":{"url":"https://api.github.com/repos/prestodb/presto/pulls/comments/91073604","pull_request_review_id":11583381,"id":91073604,"diff_hunk":"@@ -0,0 +1,286 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * 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,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.facebook.presto.tests;\n+\n+import com.facebook.presto.Session;\n+import com.facebook.presto.connector.ConnectorId;\n+import com.facebook.presto.metadata.SessionPropertyManager;\n+import com.facebook.presto.spi.type.Type;\n+import com.facebook.presto.testing.LocalQueryRunner;\n+import com.facebook.presto.testing.MaterializedResult;\n+import com.facebook.presto.testing.TestingAccessControlManager;\n+import com.facebook.presto.tpch.TpchConnectorFactory;\n+import com.google.common.collect.ImmutableMap;\n+import org.intellij.lang.annotations.Language;\n+\n+import java.util.List;\n+\n+import static com.facebook.presto.testing.TestingSession.TESTING_CATALOG;\n+import static com.facebook.presto.testing.TestingSession.testSessionBuilder;\n+import static com.facebook.presto.tpch.TpchMetadata.TINY_SCHEMA_NAME;\n+\n+public class TestLocalQueriesDeterministic\n+        extends AbstractTestQueries\n+{\n+    private final PlanDeterminismChecker determinismChecker;\n+\n+    protected TestLocalQueriesDeterministic()\n+    {\n+        super(createLocalQueryRunner());\n+        determinismChecker = new PlanDeterminismChecker((LocalQueryRunner) queryRunner);\n+    }\n+\n+    public static LocalQueryRunner createLocalQueryRunner()\n+    {\n+        Session defaultSession = testSessionBuilder()\n+                .setCatalog(\"local\")\n+                .setSchema(TINY_SCHEMA_NAME)\n+                .build();\n+\n+        LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);\n+\n+        // add the tpch catalog\n+        // local queries run directly against the generator\n+        localQueryRunner.createCatalog(\n+                defaultSession.getCatalog().get(),\n+                new TpchConnectorFactory(1),\n+                ImmutableMap.<String, String>of());\n+\n+        localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);\n+\n+        SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();\n+        sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);\n+        sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);\n+\n+        return localQueryRunner;\n+    }\n+\n+    @Override\n+    protected MaterializedResult computeActual(@Language(\"SQL\") String sql)\n+    {\n+        determinismChecker.checkPlanIsDeterministic(sql);\n+        return super.computeActual(sql);","path":"presto-tests/src/test/java/com/facebook/presto/tests/TestLocalQueriesDeterministic.java","position":73,"original_position":73,"commit_id":"238b0c707c1856851063bf72794f2ee3db16adca","original_commit_id":"238b0c707c1856851063bf72794f2ee3db16adca","user":{"login":"ArturGajowy","id":460141,"avatar_url":"https://avatars.githubusercontent.com/u/460141?v=3","gravatar_id":"","url":"https://api.github.com/users/ArturGajowy","html_url":"https://github.com/ArturGajowy","followers_url":"https://api.github.com/users/ArturGajowy/followers","following_url":"https://api.github.com/users/ArturGajowy/following{/other_user}","gists_url":"https://api.github.com/users/ArturGajowy/gists{/gist_id}","starred_url":"https://api.github.com/users/ArturGajowy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArturGajowy/subscriptions","organizations_url":"https://api.github.com/users/ArturGajowy/orgs","repos_url":"https://api.github.com/users/ArturGajowy/repos","events_url":"https://api.github.com/users/ArturGajowy/events{/privacy}","received_events_url":"https://api.github.com/users/ArturGajowy/received_events","type":"User","site_admin":false},"body":"because otherwise the assertions in the tests that use 'compute actual' fail","created_at":"2016-12-06T13:08:46Z","updated_at":"2016-12-06T13:08:46Z","html_url":"https://github.com/prestodb/presto/pull/6771#discussion_r91073604","pull_request_url":"https://api.github.com/repos/prestodb/presto/pulls/6771","_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments/91073604"},"html":{"href":"https://github.com/prestodb/presto/pull/6771#discussion_r91073604"},"pull_request":{"href":"https://api.github.com/repos/prestodb/presto/pulls/6771"}}},"pull_request":{"url":"https://api.github.com/repos/prestodb/presto/pulls/6771","id":96555860,"html_url":"https://github.com/prestodb/presto/pull/6771","diff_url":"https://github.com/prestodb/presto/pull/6771.diff","patch_url":"https://github.com/prestodb/presto/pull/6771.patch","issue_url":"https://api.github.com/repos/prestodb/presto/issues/6771","number":6771,"state":"open","locked":false,"title":"Deterministic query plans","user":{"login":"ArturGajowy","id":460141,"avatar_url":"https://avatars.githubusercontent.com/u/460141?v=3","gravatar_id":"","url":"https://api.github.com/users/ArturGajowy","html_url":"https://github.com/ArturGajowy","followers_url":"https://api.github.com/users/ArturGajowy/followers","following_url":"https://api.github.com/users/ArturGajowy/following{/other_user}","gists_url":"https://api.github.com/users/ArturGajowy/gists{/gist_id}","starred_url":"https://api.github.com/users/ArturGajowy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArturGajowy/subscriptions","organizations_url":"https://api.github.com/users/ArturGajowy/orgs","repos_url":"https://api.github.com/users/ArturGajowy/repos","events_url":"https://api.github.com/users/ArturGajowy/events{/privacy}","received_events_url":"https://api.github.com/users/ArturGajowy/received_events","type":"User","site_admin":false},"body":"This PR addresses non-determinism in query planning, as mentioned in #6579. The non-determinism severely impacts users' ability to monitor performance and tune Presto, not to mention our ability in reproducing and fixing bugs. \r\n\r\nSo far, two non-determinism sources have been identified and fixed:\r\n - use of `Ordering.arbitrary()` in EqualityInference\r\n - use of IdentityHashMap for iteration\r\n\r\nLots of instances of HashMap's in `planner` and `analyzer` have been spotted, but so far none of those has been proven to cause non-determinism (maybe they're not used for iteration?). Since queries from AbstractTestQueries did not spot any more non-determinism, I'd like to treat this PR as complete and probably add tests asserting plan determinism for all TPC-H and TPC-DS queries later.\r\n\r\nInternal review was conducted [here](https://github.com/Teradata/presto/pull/413)","created_at":"2016-12-05T15:59:36Z","updated_at":"2016-12-06T13:08:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b02ef1e5752685df57266a768751d46437c89555","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/prestodb/presto/pulls/6771/commits","review_comments_url":"https://api.github.com/repos/prestodb/presto/pulls/6771/comments","review_comment_url":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/6771/comments","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/238b0c707c1856851063bf72794f2ee3db16adca","head":{"label":"Teradata:deterministic_query_plans","ref":"deterministic_query_plans","sha":"238b0c707c1856851063bf72794f2ee3db16adca","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-11-21T11:10:12Z","pushed_at":"2016-12-06T12:59:34Z","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":188433,"stargazers_count":61,"watchers_count":61,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":26,"forks":15,"open_issues":26,"watchers":61,"default_branch":"master"}},"base":{"label":"prestodb:master","ref":"master","sha":"5e802eb66df9e4b02484d1809f8c0c78a833caf8","user":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars.githubusercontent.com/u/6882181?v=3","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://avatars.githubusercontent.com/u/6882181?v=3","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":"2016-12-06T08:02:13Z","pushed_at":"2016-12-06T12:59:36Z","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":173281,"stargazers_count":5372,"watchers_count":5372,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1683,"mirror_url":null,"open_issues_count":785,"forks":1683,"open_issues":785,"watchers":5372,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/6771"},"html":{"href":"https://github.com/prestodb/presto/pull/6771"},"issue":{"href":"https://api.github.com/repos/prestodb/presto/issues/6771"},"comments":{"href":"https://api.github.com/repos/prestodb/presto/issues/6771/comments"},"review_comments":{"href":"https://api.github.com/repos/prestodb/presto/pulls/6771/comments"},"review_comment":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prestodb/presto/pulls/6771/commits"},"statuses":{"href":"https://api.github.com/repos/prestodb/presto/statuses/238b0c707c1856851063bf72794f2ee3db16adca"}}}}
{"actor":{"display_login":"ArturGajowy"}}