{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/86143307","pull_request_review_id":6814990,"id":86143307,"diff_hunk":"@@ -477,6 +486,45 @@ private static String getFunctionType(SqlFunction function)\n         }\n \n         @Override\n+        protected Node visitShowColumnStats(ShowColumnStats node, Void context)\n+        {\n+            QualifiedName table = node.getTable();\n+            TableStatistics tableStatistics = getTableStatistics(node, table);\n+\n+            Set<String> statisticsNames = findUniqueStatisticsNames(tableStatistics);\n+\n+            List<String> resultColumnNames = buildColumnsNames(statisticsNames);\n+            SelectItem[] selectItems = buildSelectItems(resultColumnNames);\n+\n+            List<Expression> resultRows = buildStatisticsRows(tableStatistics, statisticsNames);\n+\n+            return simpleQuery(selectList(selectItems), aliased(new Values(resultRows), \"table_stats_for_\" + table, resultColumnNames));\n+        }\n+\n+        private TableStatistics getTableStatistics(ShowColumnStats node, QualifiedName table)\n+        {\n+            QualifiedObjectName qualifiedTableName = createQualifiedObjectName(session, node, table);\n+            TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName).orElseThrow(() -> new SemanticException(MISSING_TABLE, node, \"Table %s not found\", table));\n+            List<TableLayoutResult> tableLayouts = metadata.getLayouts(session, tableHandle, Constraint.alwaysTrue(), Optional.empty());\n+            TableLayoutHandle tableLayoutHandle = tableLayouts.get(0).getLayout().getHandle();\n+            return metadata.getTableStatistics(session, tableHandle, tableLayoutHandle);\n+        }\n+\n+        private static Set<String> findUniqueStatisticsNames(TableStatistics tableStatistics)\n+        {\n+            Set<String> statisticsKeys = new HashSet<>();\n+            for (String statName : tableStatistics.getTableStatistics().keySet()) {\n+                statisticsKeys.add(statName);\n+            }\n+            for (ColumnStatistics columnStats : tableStatistics.getColumnStatistics().values()) {\n+                for (String statName : columnStats.getStatistics().keySet()) {","path":"presto-main/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java","position":82,"original_position":82,"commit_id":"760dc8e1a39f9b21c45c217fcb9a745c00b9f455","original_commit_id":"760dc8e1a39f9b21c45c217fcb9a745c00b9f455","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":"Set.addAll could be used","created_at":"2016-11-02T13:45:01Z","updated_at":"2016-11-02T13:45:01Z","html_url":"https://github.com/Teradata/presto/pull/407#discussion_r86143307","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/407","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/86143307"},"html":{"href":"https://github.com/Teradata/presto/pull/407#discussion_r86143307"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/407"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/407","id":91958504,"html_url":"https://github.com/Teradata/presto/pull/407","diff_url":"https://github.com/Teradata/presto/pull/407.diff","patch_url":"https://github.com/Teradata/presto/pull/407.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/407","number":407,"state":"open","locked":false,"title":"Show column stats (without arguments)","user":{"login":"fiedukow","id":297223,"avatar_url":"https://avatars.githubusercontent.com/u/297223?v=3","gravatar_id":"","url":"https://api.github.com/users/fiedukow","html_url":"https://github.com/fiedukow","followers_url":"https://api.github.com/users/fiedukow/followers","following_url":"https://api.github.com/users/fiedukow/following{/other_user}","gists_url":"https://api.github.com/users/fiedukow/gists{/gist_id}","starred_url":"https://api.github.com/users/fiedukow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiedukow/subscriptions","organizations_url":"https://api.github.com/users/fiedukow/orgs","repos_url":"https://api.github.com/users/fiedukow/repos","events_url":"https://api.github.com/users/fiedukow/events{/privacy}","received_events_url":"https://api.github.com/users/fiedukow/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-02T12:14:11Z","updated_at":"2016-11-02T13:45:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1aacab5ce7c10af71827a6e099622e2a4a2b5427","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/407/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/407/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/407/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/760dc8e1a39f9b21c45c217fcb9a745c00b9f455","head":{"label":"Teradata:feature/show_column_stats","ref":"feature/show_column_stats","sha":"760dc8e1a39f9b21c45c217fcb9a745c00b9f455","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-10-23T09:00:15Z","pushed_at":"2016-11-02T13:35:16Z","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":168503,"stargazers_count":61,"watchers_count":61,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":28,"forks":13,"open_issues":28,"watchers":61,"default_branch":"master"}},"base":{"label":"Teradata:statistics6","ref":"statistics6","sha":"054d0be636729f92e8b545b8d7c03241273075c3","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-10-23T09:00:15Z","pushed_at":"2016-11-02T13:35:16Z","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":168503,"stargazers_count":61,"watchers_count":61,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":28,"forks":13,"open_issues":28,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/407"},"html":{"href":"https://github.com/Teradata/presto/pull/407"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/407"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/407/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/407/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/407/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/760dc8e1a39f9b21c45c217fcb9a745c00b9f455"}}}}
{"actor":{"display_login":"ArturGajowy"}}