{"action":"created","comment":{"url":"https://api.github.com/repos/prestodb/presto/pulls/comments/115433465","pull_request_review_id":36968296,"id":115433465,"diff_hunk":"@@ -1354,11 +1356,26 @@ else if (expression instanceof LongLiteral) {\n                     }\n \n                     // otherwise, just use the expression as is\n+                    boolean orderByOnExpression = false;\n                     if (orderByExpression == null) {\n                         orderByExpression = expression;\n+                        orderByOnExpression = true;\n                     }\n \n                     ExpressionAnalysis expressionAnalysis = analyzeExpression(orderByExpression, sourceScope);\n+                    if (orderByOnExpression) {\n+                        // Try to resolve within orderByScope. If it is possible, then we warn - standard behavior differs from legacy one.\n+                        for (Map.Entry<Expression, FieldId> columnExpression : expressionAnalysis.getColumnReferences().entrySet()) {\n+                            Optional<ResolvedField> resolvedField = orderByScope.tryResolveField(columnExpression.getKey());\n+                            if (resolvedField.isPresent()) {\n+                                if (!FieldId.from(resolvedField.get()).equals(columnExpression.getValue())) {","path":"presto-main/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","position":93,"original_position":32,"commit_id":"87f480f15abad38626bb5f7d108be0968ceb1618","original_commit_id":"3289f547340bf9091291e3e871f92e1ec324af22","user":{"login":"sopel39","id":5989165,"avatar_url":"https://avatars2.githubusercontent.com/u/5989165?v=3","gravatar_id":"","url":"https://api.github.com/users/sopel39","html_url":"https://github.com/sopel39","followers_url":"https://api.github.com/users/sopel39/followers","following_url":"https://api.github.com/users/sopel39/following{/other_user}","gists_url":"https://api.github.com/users/sopel39/gists{/gist_id}","starred_url":"https://api.github.com/users/sopel39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sopel39/subscriptions","organizations_url":"https://api.github.com/users/sopel39/orgs","repos_url":"https://api.github.com/users/sopel39/repos","events_url":"https://api.github.com/users/sopel39/events{/privacy}","received_events_url":"https://api.github.com/users/sopel39/received_events","type":"User","site_admin":false},"body":"OK. Now I see. It seems that `expressionAnalysis` doesn't contain information about subquries. Therefore we won't provide user with warning for query like:\r\n```\r\nSELECT 1 as a FROM (VALUES 1) t(a) ORDER BY (SELECT a FROM (VALUES 2) t(b));\r\n```\r\nPlease add tests:\r\n```\r\n(no warning, unsupported) SELECT 1 as a FROM (VALUES 1) t(a) ORDER BY (SELECT a FROM (VALUES 2) t(b))\r\n(warning) SELECT 'a' as a FROM (VALUES 1) t(a) ORDER BY transform(array[1], x->a)[1];\r\n(no warning) SELECT 'a' as a FROM (VALUES 1) t(a) ORDER BY transform(array[1], a->a)[1];\r\n```","created_at":"2017-05-09T08:28:13Z","updated_at":"2017-05-09T08:28:13Z","html_url":"https://github.com/prestodb/presto/pull/7852#discussion_r115433465","pull_request_url":"https://api.github.com/repos/prestodb/presto/pulls/7852","_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments/115433465"},"html":{"href":"https://github.com/prestodb/presto/pull/7852#discussion_r115433465"},"pull_request":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7852"}}},"pull_request":{"url":"https://api.github.com/repos/prestodb/presto/pulls/7852","id":116411608,"html_url":"https://github.com/prestodb/presto/pull/7852","diff_url":"https://github.com/prestodb/presto/pull/7852.diff","patch_url":"https://github.com/prestodb/presto/pull/7852.patch","issue_url":"https://api.github.com/repos/prestodb/presto/issues/7852","number":7852,"state":"open","locked":false,"title":"Add planner warnings","user":{"login":"idemura","id":2356456,"avatar_url":"https://avatars2.githubusercontent.com/u/2356456?v=3","gravatar_id":"","url":"https://api.github.com/users/idemura","html_url":"https://github.com/idemura","followers_url":"https://api.github.com/users/idemura/followers","following_url":"https://api.github.com/users/idemura/following{/other_user}","gists_url":"https://api.github.com/users/idemura/gists{/gist_id}","starred_url":"https://api.github.com/users/idemura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idemura/subscriptions","organizations_url":"https://api.github.com/users/idemura/orgs","repos_url":"https://api.github.com/users/idemura/repos","events_url":"https://api.github.com/users/idemura/events{/privacy}","received_events_url":"https://api.github.com/users/idemura/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-04-18T20:18:03Z","updated_at":"2017-05-09T08:28:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c074647b13a89df16789bce9f9a46caa82f117af","assignee":{"login":"martint","id":14387,"avatar_url":"https://avatars0.githubusercontent.com/u/14387?v=3","gravatar_id":"","url":"https://api.github.com/users/martint","html_url":"https://github.com/martint","followers_url":"https://api.github.com/users/martint/followers","following_url":"https://api.github.com/users/martint/following{/other_user}","gists_url":"https://api.github.com/users/martint/gists{/gist_id}","starred_url":"https://api.github.com/users/martint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martint/subscriptions","organizations_url":"https://api.github.com/users/martint/orgs","repos_url":"https://api.github.com/users/martint/repos","events_url":"https://api.github.com/users/martint/events{/privacy}","received_events_url":"https://api.github.com/users/martint/received_events","type":"User","site_admin":false},"assignees":[{"login":"martint","id":14387,"avatar_url":"https://avatars0.githubusercontent.com/u/14387?v=3","gravatar_id":"","url":"https://api.github.com/users/martint","html_url":"https://github.com/martint","followers_url":"https://api.github.com/users/martint/followers","following_url":"https://api.github.com/users/martint/following{/other_user}","gists_url":"https://api.github.com/users/martint/gists{/gist_id}","starred_url":"https://api.github.com/users/martint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martint/subscriptions","organizations_url":"https://api.github.com/users/martint/orgs","repos_url":"https://api.github.com/users/martint/repos","events_url":"https://api.github.com/users/martint/events{/privacy}","received_events_url":"https://api.github.com/users/martint/received_events","type":"User","site_admin":false},{"login":"nezihyigitbasi","id":1223839,"avatar_url":"https://avatars0.githubusercontent.com/u/1223839?v=3","gravatar_id":"","url":"https://api.github.com/users/nezihyigitbasi","html_url":"https://github.com/nezihyigitbasi","followers_url":"https://api.github.com/users/nezihyigitbasi/followers","following_url":"https://api.github.com/users/nezihyigitbasi/following{/other_user}","gists_url":"https://api.github.com/users/nezihyigitbasi/gists{/gist_id}","starred_url":"https://api.github.com/users/nezihyigitbasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nezihyigitbasi/subscriptions","organizations_url":"https://api.github.com/users/nezihyigitbasi/orgs","repos_url":"https://api.github.com/users/nezihyigitbasi/repos","events_url":"https://api.github.com/users/nezihyigitbasi/events{/privacy}","received_events_url":"https://api.github.com/users/nezihyigitbasi/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/prestodb/presto/pulls/7852/commits","review_comments_url":"https://api.github.com/repos/prestodb/presto/pulls/7852/comments","review_comment_url":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/7852/comments","statuses_url":"https://api.github.com/repos/prestodb/presto/statuses/87f480f15abad38626bb5f7d108be0968ceb1618","head":{"label":"idemura:warn","ref":"warn","sha":"87f480f15abad38626bb5f7d108be0968ceb1618","user":{"login":"idemura","id":2356456,"avatar_url":"https://avatars2.githubusercontent.com/u/2356456?v=3","gravatar_id":"","url":"https://api.github.com/users/idemura","html_url":"https://github.com/idemura","followers_url":"https://api.github.com/users/idemura/followers","following_url":"https://api.github.com/users/idemura/following{/other_user}","gists_url":"https://api.github.com/users/idemura/gists{/gist_id}","starred_url":"https://api.github.com/users/idemura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idemura/subscriptions","organizations_url":"https://api.github.com/users/idemura/orgs","repos_url":"https://api.github.com/users/idemura/repos","events_url":"https://api.github.com/users/idemura/events{/privacy}","received_events_url":"https://api.github.com/users/idemura/received_events","type":"User","site_admin":false},"repo":{"id":66978007,"name":"presto","full_name":"idemura/presto","owner":{"login":"idemura","id":2356456,"avatar_url":"https://avatars2.githubusercontent.com/u/2356456?v=3","gravatar_id":"","url":"https://api.github.com/users/idemura","html_url":"https://github.com/idemura","followers_url":"https://api.github.com/users/idemura/followers","following_url":"https://api.github.com/users/idemura/following{/other_user}","gists_url":"https://api.github.com/users/idemura/gists{/gist_id}","starred_url":"https://api.github.com/users/idemura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idemura/subscriptions","organizations_url":"https://api.github.com/users/idemura/orgs","repos_url":"https://api.github.com/users/idemura/repos","events_url":"https://api.github.com/users/idemura/events{/privacy}","received_events_url":"https://api.github.com/users/idemura/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/idemura/presto","description":"Distributed SQL query engine for big data","fork":true,"url":"https://api.github.com/repos/idemura/presto","forks_url":"https://api.github.com/repos/idemura/presto/forks","keys_url":"https://api.github.com/repos/idemura/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/idemura/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/idemura/presto/teams","hooks_url":"https://api.github.com/repos/idemura/presto/hooks","issue_events_url":"https://api.github.com/repos/idemura/presto/issues/events{/number}","events_url":"https://api.github.com/repos/idemura/presto/events","assignees_url":"https://api.github.com/repos/idemura/presto/assignees{/user}","branches_url":"https://api.github.com/repos/idemura/presto/branches{/branch}","tags_url":"https://api.github.com/repos/idemura/presto/tags","blobs_url":"https://api.github.com/repos/idemura/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/idemura/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/idemura/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/idemura/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/idemura/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/idemura/presto/languages","stargazers_url":"https://api.github.com/repos/idemura/presto/stargazers","contributors_url":"https://api.github.com/repos/idemura/presto/contributors","subscribers_url":"https://api.github.com/repos/idemura/presto/subscribers","subscription_url":"https://api.github.com/repos/idemura/presto/subscription","commits_url":"https://api.github.com/repos/idemura/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/idemura/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/idemura/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/idemura/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/idemura/presto/contents/{+path}","compare_url":"https://api.github.com/repos/idemura/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/idemura/presto/merges","archive_url":"https://api.github.com/repos/idemura/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/idemura/presto/downloads","issues_url":"https://api.github.com/repos/idemura/presto/issues{/number}","pulls_url":"https://api.github.com/repos/idemura/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/idemura/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/idemura/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/idemura/presto/labels{/name}","releases_url":"https://api.github.com/repos/idemura/presto/releases{/id}","deployments_url":"https://api.github.com/repos/idemura/presto/deployments","created_at":"2016-08-30T21:09:06Z","updated_at":"2016-08-30T21:09:21Z","pushed_at":"2017-05-08T20:17:19Z","git_url":"git://github.com/idemura/presto.git","ssh_url":"git@github.com:idemura/presto.git","clone_url":"https://github.com/idemura/presto.git","svn_url":"https://github.com/idemura/presto","homepage":"https://prestodb.io","size":71853,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prestodb:master","ref":"master","sha":"f1b346522f53ff82ca88cc7c16e22d8f0c3da89a","user":{"login":"prestodb","id":6882181,"avatar_url":"https://avatars3.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://avatars3.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":"2017-05-09T04:23:10Z","pushed_at":"2017-05-09T08:24:04Z","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":71995,"stargazers_count":5965,"watchers_count":5965,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1924,"mirror_url":null,"open_issues_count":937,"forks":1924,"open_issues":937,"watchers":5965,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7852"},"html":{"href":"https://github.com/prestodb/presto/pull/7852"},"issue":{"href":"https://api.github.com/repos/prestodb/presto/issues/7852"},"comments":{"href":"https://api.github.com/repos/prestodb/presto/issues/7852/comments"},"review_comments":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7852/comments"},"review_comment":{"href":"https://api.github.com/repos/prestodb/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prestodb/presto/pulls/7852/commits"},"statuses":{"href":"https://api.github.com/repos/prestodb/presto/statuses/87f480f15abad38626bb5f7d108be0968ceb1618"}}}}
{"actor":{"display_login":"sopel39"}}