{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/102778675","pull_request_review_id":23546182,"id":102778675,"diff_hunk":"@@ -408,7 +408,13 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat\n   }\n \n   private def defaultTablePath(tableIdent: TableIdentifier): String = {\n-    val dbLocation = getDatabase(tableIdent.database.get).locationUri\n+    // default database's location always use the warehouse path,\n+    // and since the location of database stored in metastore is qualified,\n+    // here we also make qualify for warehouse location\n+    val dbLocation = if (tableIdent.database.orNull == SessionCatalog.DEFAULT_DATABASE) {\n+      SessionCatalog.makeQualifiedPath(conf.get(WAREHOUSE_PATH), hadoopConf).toString\n+    } else getDatabase(tableIdent.database.get).locationUri","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala","position":10,"original_position":10,"commit_id":"8f8063f8c4e11cb4f6158c90d21d8a0985d38584","original_commit_id":"8f8063f8c4e11cb4f6158c90d21d8a0985d38584","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":"This is duplicate code. We should call the same one. ","created_at":"2017-02-23T18:10:32Z","updated_at":"2017-02-23T18:10:32Z","html_url":"https://github.com/apache/spark/pull/17001#discussion_r102778675","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/17001","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/102778675"},"html":{"href":"https://github.com/apache/spark/pull/17001#discussion_r102778675"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/17001"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/17001","id":107020786,"html_url":"https://github.com/apache/spark/pull/17001","diff_url":"https://github.com/apache/spark/pull/17001.diff","patch_url":"https://github.com/apache/spark/pull/17001.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/17001","number":17001,"state":"open","locked":false,"title":"[SPARK-19667][SQL]create table with hiveenabled in default database use warehouse path instead of the location of default database","user":{"login":"windpiger","id":12979185,"avatar_url":"https://avatars.githubusercontent.com/u/12979185?v=3","gravatar_id":"","url":"https://api.github.com/users/windpiger","html_url":"https://github.com/windpiger","followers_url":"https://api.github.com/users/windpiger/followers","following_url":"https://api.github.com/users/windpiger/following{/other_user}","gists_url":"https://api.github.com/users/windpiger/gists{/gist_id}","starred_url":"https://api.github.com/users/windpiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windpiger/subscriptions","organizations_url":"https://api.github.com/users/windpiger/orgs","repos_url":"https://api.github.com/users/windpiger/repos","events_url":"https://api.github.com/users/windpiger/events{/privacy}","received_events_url":"https://api.github.com/users/windpiger/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nCurrently, when we create a managed table with HiveEnabled in default database,  Spark will use the location of default database as the table's location, this is ok in non-shared metastore.\r\n\r\nWhile if we use a shared metastore between different clusters， for example，\r\n1) there is a hive metastore in Cluster-A, and the metastore use a remote mysql as its db, and create a default database in metastore, then the location of the default database is the path in Cluster-A\r\n\r\n2) then we create another Cluster-B, and Cluster-B also use the same remote mysql as its metastore's db, so the default database conf in Cluster-B download from mysql, which location is the path of Cluster-A\r\n\r\n3) then we create a table in Cluster-B in default database, it will throw an exception, that UnknowHost Cluster-A\r\n\r\nIn Hive2.0.0, it is allowed to create a table in default database which shared between clusters , and this action is not allowed in other database, just for default.\r\n\r\nAs a spark User, we will want to have the same action as Hive, thus we can create table in default database using a shared mysql in metastore.\r\n\r\n## How was this patch tested?\r\nunit test added","created_at":"2017-02-20T14:52:25Z","updated_at":"2017-02-23T18:10:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f9f241a36eabee8db044e6838043fa6ff9f5983","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/17001/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/17001/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/17001/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/8f8063f8c4e11cb4f6158c90d21d8a0985d38584","head":{"label":"windpiger:defaultDBPathInHive","ref":"defaultDBPathInHive","sha":"8f8063f8c4e11cb4f6158c90d21d8a0985d38584","user":{"login":"windpiger","id":12979185,"avatar_url":"https://avatars.githubusercontent.com/u/12979185?v=3","gravatar_id":"","url":"https://api.github.com/users/windpiger","html_url":"https://github.com/windpiger","followers_url":"https://api.github.com/users/windpiger/followers","following_url":"https://api.github.com/users/windpiger/following{/other_user}","gists_url":"https://api.github.com/users/windpiger/gists{/gist_id}","starred_url":"https://api.github.com/users/windpiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windpiger/subscriptions","organizations_url":"https://api.github.com/users/windpiger/orgs","repos_url":"https://api.github.com/users/windpiger/repos","events_url":"https://api.github.com/users/windpiger/events{/privacy}","received_events_url":"https://api.github.com/users/windpiger/received_events","type":"User","site_admin":false},"repo":{"id":70575274,"name":"spark","full_name":"windpiger/spark","owner":{"login":"windpiger","id":12979185,"avatar_url":"https://avatars.githubusercontent.com/u/12979185?v=3","gravatar_id":"","url":"https://api.github.com/users/windpiger","html_url":"https://github.com/windpiger","followers_url":"https://api.github.com/users/windpiger/followers","following_url":"https://api.github.com/users/windpiger/following{/other_user}","gists_url":"https://api.github.com/users/windpiger/gists{/gist_id}","starred_url":"https://api.github.com/users/windpiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windpiger/subscriptions","organizations_url":"https://api.github.com/users/windpiger/orgs","repos_url":"https://api.github.com/users/windpiger/repos","events_url":"https://api.github.com/users/windpiger/events{/privacy}","received_events_url":"https://api.github.com/users/windpiger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/windpiger/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/windpiger/spark","forks_url":"https://api.github.com/repos/windpiger/spark/forks","keys_url":"https://api.github.com/repos/windpiger/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/windpiger/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/windpiger/spark/teams","hooks_url":"https://api.github.com/repos/windpiger/spark/hooks","issue_events_url":"https://api.github.com/repos/windpiger/spark/issues/events{/number}","events_url":"https://api.github.com/repos/windpiger/spark/events","assignees_url":"https://api.github.com/repos/windpiger/spark/assignees{/user}","branches_url":"https://api.github.com/repos/windpiger/spark/branches{/branch}","tags_url":"https://api.github.com/repos/windpiger/spark/tags","blobs_url":"https://api.github.com/repos/windpiger/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/windpiger/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/windpiger/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/windpiger/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/windpiger/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/windpiger/spark/languages","stargazers_url":"https://api.github.com/repos/windpiger/spark/stargazers","contributors_url":"https://api.github.com/repos/windpiger/spark/contributors","subscribers_url":"https://api.github.com/repos/windpiger/spark/subscribers","subscription_url":"https://api.github.com/repos/windpiger/spark/subscription","commits_url":"https://api.github.com/repos/windpiger/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/windpiger/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/windpiger/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/windpiger/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/windpiger/spark/contents/{+path}","compare_url":"https://api.github.com/repos/windpiger/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/windpiger/spark/merges","archive_url":"https://api.github.com/repos/windpiger/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/windpiger/spark/downloads","issues_url":"https://api.github.com/repos/windpiger/spark/issues{/number}","pulls_url":"https://api.github.com/repos/windpiger/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/windpiger/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/windpiger/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/windpiger/spark/labels{/name}","releases_url":"https://api.github.com/repos/windpiger/spark/releases{/id}","deployments_url":"https://api.github.com/repos/windpiger/spark/deployments","created_at":"2016-10-11T08:59:56Z","updated_at":"2016-10-11T09:00:21Z","pushed_at":"2017-02-23T15:09:24Z","git_url":"git://github.com/windpiger/spark.git","ssh_url":"git@github.com:windpiger/spark.git","clone_url":"https://github.com/windpiger/spark.git","svn_url":"https://github.com/windpiger/spark","homepage":null,"size":262581,"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":"master"}},"base":{"label":"apache:master","ref":"master","sha":"1a45d2b2cc6466841fb73da21a61b61f14a5d5fb","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":"2017-02-23T09:42:38Z","pushed_at":"2017-02-23T17:20:16Z","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":263603,"stargazers_count":11778,"watchers_count":11778,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11066,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":454,"forks":11066,"open_issues":454,"watchers":11778,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/17001"},"html":{"href":"https://github.com/apache/spark/pull/17001"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/17001"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/17001/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/17001/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/17001/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/8f8063f8c4e11cb4f6158c90d21d8a0985d38584"}}}}
{"actor":{"display_login":"gatorsmile"}}