{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/12716","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/12716/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/12716/comments","events_url":"https://api.github.com/repos/apache/spark/issues/12716/events","html_url":"https://github.com/apache/spark/pull/12716","id":151255745,"number":12716,"title":"[Spark-14933][SQL] Failed to create view out of a parquet or orc table","user":{"login":"xwu0226","id":14225992,"avatar_url":"https://avatars.githubusercontent.com/u/14225992?v=3","gravatar_id":"","url":"https://api.github.com/users/xwu0226","html_url":"https://github.com/xwu0226","followers_url":"https://api.github.com/users/xwu0226/followers","following_url":"https://api.github.com/users/xwu0226/following{/other_user}","gists_url":"https://api.github.com/users/xwu0226/gists{/gist_id}","starred_url":"https://api.github.com/users/xwu0226/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xwu0226/subscriptions","organizations_url":"https://api.github.com/users/xwu0226/orgs","repos_url":"https://api.github.com/users/xwu0226/repos","events_url":"https://api.github.com/users/xwu0226/events{/privacy}","received_events_url":"https://api.github.com/users/xwu0226/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-26T22:37:18Z","updated_at":"2016-05-04T21:01:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12716","html_url":"https://github.com/apache/spark/pull/12716","diff_url":"https://github.com/apache/spark/pull/12716.diff","patch_url":"https://github.com/apache/spark/pull/12716.patch"},"body":"## What changes were proposed in this pull request?\r\nIf a table is created as parquet or ORC table with hive syntaxt DDL, such as\r\n`create table t1 (c1 int, c2 string) stored as parquet`\r\nThe following command will fail\r\n`create view v1 as select * from t1`\r\nThe root cause is that when resolving the relation for the parquet table t1, `HiveMetaStoreCatalog` convert it to a `LogicalRelation`, but without a tableIdentifier attached to it. So when `SQLBuilder `is trying to create a `SQLTable `out of it, the `LogicalRelation` created earlier does not mach due to the lack of tableIdentifier. Thus, `SQLBuilder.toSQL `can not recognize this logical plan and issue exception. \r\n\r\nThe fix in this PR is to also give `TableIdentifier `to the `LogicalRelation `created for parquet or orc table in `HiveMetaStoreCatalog`\r\n\r\n## How was this patch tested?\r\ntestcases created and dev/run-tests is run.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/217001624","html_url":"https://github.com/apache/spark/pull/12716#issuecomment-217001624","issue_url":"https://api.github.com/repos/apache/spark/issues/12716","id":217001624,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T21:01:49Z","updated_at":"2016-05-04T21:01:49Z","body":"Merged build finished. Test PASSed."}}