{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/14531","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/14531/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/14531/comments","events_url":"https://api.github.com/repos/apache/spark/issues/14531/events","html_url":"https://github.com/apache/spark/pull/14531","id":169841429,"number":14531,"title":"[SPARK-16943] [SPARK-16942] [SQL] Fix multiple bugs in CREATE TABLE LIKE command","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},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":29,"created_at":"2016-08-08T04:29:53Z","updated_at":"2016-08-31T05:48:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14531","html_url":"https://github.com/apache/spark/pull/14531","diff_url":"https://github.com/apache/spark/pull/14531.diff","patch_url":"https://github.com/apache/spark/pull/14531.patch"},"body":"### What changes were proposed in this pull request?\r\nThe existing `CREATE TABLE LIKE` command has multiple issues:\r\n\r\n- The generated table is non-empty when the source table is a data source table. The major reason is the data source table is using the table property `path` to store the location of table contents. Currently, we keep it unchanged. Thus, we still create the same table with the same location.\r\n\r\n- The table type of the generated table is `EXTERNAL` when the source table is an external Hive Serde table. Currently, we explicitly set it to `MANAGED`, but Hive is checking the table property `EXTERNAL` to decide whether the table is `EXTERNAL` or not. (See https://github.com/apache/hive/blob/master/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L1407-L1408) Thus, the created table is still `EXTERNAL`. \r\n\r\n- When the source table is a `VIEW`, the metadata of the generated table contains the original view text and view original text. So far, this does not break anything, but it could cause something wrong in Hive. (For example, https://github.com/apache/hive/blob/master/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L1405-L1406)\r\n\r\n- The issue regarding the table `comment`. To follow what Hive does, the table comment should be cleaned, but the column comments should be still kept.\r\n\r\n- The `INDEX` table is not supported. Thus, we should throw an exception in this case. \r\n\r\n- `owner` should not be retained. `ToHiveTable` set it [here](https://github.com/apache/spark/blob/e679bc3c1cd418ef0025d2ecbc547c9660cac433/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala#L793) no matter which value we set in `CatalogTable`. We set it to an empty string for avoiding the confusing output in Explain.\r\n\r\n- Add a support for temp tables\r\n\r\n- Like Hive, we should not copy the table properties from the source table to the created table, especially for the statistics-related properties, which could be wrong in the created table.\r\n\r\n- `unsupportedFeatures` should not be copied from the source table. The created table does not have these unsupported features.\r\n\r\nThis PR is to fix the above issues. \r\n\r\n### How was this patch tested?\r\nImprove the test coverage by adding more test cases"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/243664955","html_url":"https://github.com/apache/spark/pull/14531#issuecomment-243664955","issue_url":"https://api.github.com/repos/apache/spark/issues/14531","id":243664955,"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},"created_at":"2016-08-31T05:48:50Z","updated_at":"2016-08-31T05:48:50Z","body":"Let me do it now."}}
{"actor":{"display_login":"gatorsmile"}}