{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/65655636","id":65655636,"diff_hunk":"@@ -140,6 +170,32 @@ case class CatalogTable(\n       locationUri, inputFormat, outputFormat, serde, compressed, serdeProperties))\n   }\n \n+  override def toString: String = {\n+    val tableProperties = properties.map(p => p._1 + \"=\" + p._2).mkString(\"[\", \", \", \"]\")\n+    val partitionColumns = partitionColumnNames.map(\"`\" + _ + \"`\").mkString(\"[\", \", \", \"]\")\n+    val sortColumns = sortColumnNames.map(\"`\" + _ + \"`\").mkString(\"[\", \", \", \"]\")\n+    val bucketColumns = bucketColumnNames.map(\"`\" + _ + \"`\").mkString(\"[\", \", \", \"]\")\n+\n+    val output =\n+      Seq(s\"Table:${identifier.quotedString}\",\n+        if (owner.nonEmpty) s\"Owner:$owner\" else \"\",\n+        s\"Created:${new Date(createTime).toString}\",\n+        s\"Last Access:${new Date(lastAccessTime).toString}\",\n+        s\"Type:${tableType.name}\",\n+        if (schema.nonEmpty) s\"Schema:${schema.mkString(\"[\", \", \", \"]\")}\" else \"\",\n+        if (partitionColumnNames.nonEmpty) s\"Partition Columns:$partitionColumns\" else \"\",\n+        if (numBuckets != -1) s\"Num Buckets:$numBuckets\" else \"\",\n+        if (bucketColumnNames.nonEmpty) s\"Bucket Columns:$bucketColumns\" else \"\",\n+        if (sortColumnNames.nonEmpty) s\"Sort Columns:$sortColumns\" else \"\",\n+        viewOriginalText.map(\"Original View:\" + _).getOrElse(\"\"),\n+        viewText.map(\"View:\" + _).getOrElse(\"\"),\n+        comment.map(\"Comment:\" + _).getOrElse(\"\"),\n+        if (properties.nonEmpty) s\"Properties:$tableProperties\" else \"\",\n+        s\"$storage\")\n+\n+    output.filter(_.nonEmpty).mkString(\"CatalogTable(\", \", \", \")\")","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala","position":83,"original_position":83,"commit_id":"505321f247eefe32d3a791a312191e9e626968e0","original_commit_id":"505321f247eefe32d3a791a312191e9e626968e0","user":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"body":"Since we are using `, ` as a separator, the output of EXPLAIN is like:\r\n```\r\nCreateTableCommand CatalogTable(Table:`extTable_with_partitions`, Created:Thu Jun 02 21:25:26 PDT 2016, Last Access:Wed Dec 31 15:59:59 PST 1969, Type:EXTERNAL, Schema:[`key` int, `value` string, `ds` string, `hr` string], Partition Columns:[`ds`, `hr`], Storage(Location:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-472564ea-a321-447b-8224-7790edf454ab, InputFormat:org.apache.hadoop.mapred.TextInputFormat, OutputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat)), false\r\n```\r\n\r\nIf we change it to `\\n`, it will be like\r\n```\r\nCreateTableCommand CatalogTable(Table:`extTable_with_partitions`\r\nCreated:Thu Jun 02 21:28:32 PDT 2016\r\nLast Access:Wed Dec 31 15:59:59 PST 1969\r\nType:EXTERNAL\r\nSchema:[`key` int, `value` string, `ds` string, `hr` string]\r\nPartition Columns:[`ds`, `hr`]\r\nStorage(Location:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-a8e78990-3d9c-4f83-9ec4-6121473c1d09, InputFormat:org.apache.hadoop.mapred.TextInputFormat, OutputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat)), false\r\n```\r\n\r\nAnother option is to use `\\n\\t` in `mkString` (i.e., `mkString(\"CatalogTable(\\n\\t\", \"\\n\\t\", \")\")`). Then, it will become \r\n```\r\nCreateTableCommand CatalogTable(\r\n\tTable:`extTable_with_partitions`\r\n\tCreated:Thu Jun 02 21:30:54 PDT 2016\r\n\tLast Access:Wed Dec 31 15:59:59 PST 1969\r\n\tType:EXTERNAL\r\n\tSchema:[`key` int, `value` string, `ds` string, `hr` string]\r\n\tPartition Columns:[`ds`, `hr`]\r\n\tStorage(Location:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-a06083b8-8e88-4d07-9ff0-d6bd8d943ad3, InputFormat:org.apache.hadoop.mapred.TextInputFormat, OutputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat)), false\r\n```","created_at":"2016-06-03T04:33:03Z","updated_at":"2016-06-03T04:33:03Z","html_url":"https://github.com/apache/spark/pull/13070#discussion_r65655636","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/13070","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/65655636"},"html":{"href":"https://github.com/apache/spark/pull/13070#discussion_r65655636"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/13070"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13070","id":69778775,"html_url":"https://github.com/apache/spark/pull/13070","diff_url":"https://github.com/apache/spark/pull/13070.diff","patch_url":"https://github.com/apache/spark/pull/13070.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/13070","number":13070,"state":"open","locked":false,"title":"[SPARK-15286] [SQL] Make the output readable for EXPLAIN CREATE TABLE and DESC EXTENDED","user":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"body":"#### What changes were proposed in this pull request?\r\nBefore this PR, the output of EXPLAIN of following SQL is like\r\n\r\n```SQL\r\nCREATE EXTERNAL TABLE extTable_with_partitions (key INT, value STRING)\r\nPARTITIONED BY (ds STRING, hr STRING)\r\nLOCATION '/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-b39a6185-8981-403b-a4aa-36fb2f4ca8a9'\r\n```\r\n``ExecutedCommand CreateTableCommand CatalogTable(`extTable_with_partitions`,CatalogTableType(EXTERNAL),CatalogStorageFormat(Some(/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-dd234718-e85d-4c5a-8353-8f1834ac0323),Some(org.apache.hadoop.mapred.TextInputFormat),Some(org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat),None,false,Map()),List(CatalogColumn(key,int,true,None), CatalogColumn(value,string,true,None), CatalogColumn(ds,string,true,None), CatalogColumn(hr,string,true,None)),List(ds, hr),List(),List(),-1,,1463026413544,-1,Map(),None,None,None), false``\r\n\r\nAfter this PR, the output is like\r\n\r\n``ExecutedCommand CreateTableCommand CatalogTable(Table:`extTable_with_partitions`, Created:Thu May 12 00:32:35 PDT 2016, Last Access:Wed Dec 31 15:59:59 PST 1969, Type:EXTERNAL, Schema:[`key` int, `value` string, `ds` string, `hr` string], Partition Columns:[`ds`, `hr`], Storage(Location:/private/var/folders/4b/sgmfldk15js406vk7lw5llzw0000gn/T/spark-508c0d74-c658-4c9d-8e6b-17f2331c2c63, InputFormat:org.apache.hadoop.mapred.TextInputFormat, OutputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat)), false``\r\n\r\nThis is also applicable to `DESC EXTENDED`. However, this does not have special handling for Data Source Tables. If needed, we need to move the logics of `DDLUtil`. Let me know if we should do it in this PR. Thanks! @rxin @liancheng \r\n\r\n#### How was this patch tested?\r\nManual testing","created_at":"2016-05-12T04:41:17Z","updated_at":"2016-06-03T04:33:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"495eb0e3364b992dc8bd10002e8b35efa144da37","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/13070/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/13070/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/13070/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/505321f247eefe32d3a791a312191e9e626968e0","head":{"label":"gatorsmile:betterExplainCatalogTable","ref":"betterExplainCatalogTable","sha":"505321f247eefe32d3a791a312191e9e626968e0","user":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"repo":{"id":44710950,"name":"spark","full_name":"gatorsmile/spark","owner":{"login":"gatorsmile","id":11567269,"avatar_url":"https://avatars.githubusercontent.com/u/11567269?v=3","gravatar_id":"","url":"https://api.github.com/users/gatorsmile","html_url":"https://github.com/gatorsmile","followers_url":"https://api.github.com/users/gatorsmile/followers","following_url":"https://api.github.com/users/gatorsmile/following{/other_user}","gists_url":"https://api.github.com/users/gatorsmile/gists{/gist_id}","starred_url":"https://api.github.com/users/gatorsmile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatorsmile/subscriptions","organizations_url":"https://api.github.com/users/gatorsmile/orgs","repos_url":"https://api.github.com/users/gatorsmile/repos","events_url":"https://api.github.com/users/gatorsmile/events{/privacy}","received_events_url":"https://api.github.com/users/gatorsmile/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gatorsmile/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/gatorsmile/spark","forks_url":"https://api.github.com/repos/gatorsmile/spark/forks","keys_url":"https://api.github.com/repos/gatorsmile/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gatorsmile/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gatorsmile/spark/teams","hooks_url":"https://api.github.com/repos/gatorsmile/spark/hooks","issue_events_url":"https://api.github.com/repos/gatorsmile/spark/issues/events{/number}","events_url":"https://api.github.com/repos/gatorsmile/spark/events","assignees_url":"https://api.github.com/repos/gatorsmile/spark/assignees{/user}","branches_url":"https://api.github.com/repos/gatorsmile/spark/branches{/branch}","tags_url":"https://api.github.com/repos/gatorsmile/spark/tags","blobs_url":"https://api.github.com/repos/gatorsmile/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gatorsmile/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gatorsmile/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/gatorsmile/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gatorsmile/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/gatorsmile/spark/languages","stargazers_url":"https://api.github.com/repos/gatorsmile/spark/stargazers","contributors_url":"https://api.github.com/repos/gatorsmile/spark/contributors","subscribers_url":"https://api.github.com/repos/gatorsmile/spark/subscribers","subscription_url":"https://api.github.com/repos/gatorsmile/spark/subscription","commits_url":"https://api.github.com/repos/gatorsmile/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/gatorsmile/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/gatorsmile/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/gatorsmile/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/gatorsmile/spark/contents/{+path}","compare_url":"https://api.github.com/repos/gatorsmile/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gatorsmile/spark/merges","archive_url":"https://api.github.com/repos/gatorsmile/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gatorsmile/spark/downloads","issues_url":"https://api.github.com/repos/gatorsmile/spark/issues{/number}","pulls_url":"https://api.github.com/repos/gatorsmile/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/gatorsmile/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/gatorsmile/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gatorsmile/spark/labels{/name}","releases_url":"https://api.github.com/repos/gatorsmile/spark/releases{/id}","deployments_url":"https://api.github.com/repos/gatorsmile/spark/deployments","created_at":"2015-10-21T23:48:23Z","updated_at":"2015-10-21T23:48:54Z","pushed_at":"2016-06-03T03:04:57Z","git_url":"git://github.com/gatorsmile/spark.git","ssh_url":"git@github.com:gatorsmile/spark.git","clone_url":"https://github.com/gatorsmile/spark.git","svn_url":"https://github.com/gatorsmile/spark","homepage":null,"size":178495,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"binaryOutput"}},"base":{"label":"apache:master","ref":"master","sha":"472f16181d199684996a156b0e429bc525d65a57","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-06-03T02:43:41Z","pushed_at":"2016-06-03T03:06:57Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":496625,"stargazers_count":8781,"watchers_count":8781,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8161,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":434,"forks":8161,"open_issues":434,"watchers":8781,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/13070"},"html":{"href":"https://github.com/apache/spark/pull/13070"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/13070"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/13070/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/13070/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/13070/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/505321f247eefe32d3a791a312191e9e626968e0"}}}}
{"actor":{"display_login":"gatorsmile"}}