{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/67907323","id":67907323,"diff_hunk":"@@ -531,18 +531,29 @@ private[hive] class HiveMetastoreCatalog(sparkSession: SparkSession) extends Log\n /**\n  * An override of the standard HDFS listing based catalog, that overrides the partition spec with\n  * the information from the metastore.\n+ * @param tableBasePath The default base path of the Hive metastore table\n+ * @param partitionSpec The partition specifications from Hive metastore\n  */\n private[hive] class MetaStoreFileCatalog(\n     sparkSession: SparkSession,\n-    paths: Seq[Path],\n-    partitionSpecFromHive: PartitionSpec)\n+    tableBasePath: Path,\n+    override val partitionSpec: PartitionSpec)\n   extends ListingFileCatalog(\n     sparkSession,\n-    paths,\n+    MetaStoreFileCatalog.getPaths(tableBasePath, partitionSpec),\n     Map.empty,\n-    Some(partitionSpecFromHive.partitionColumns)) {\n+    Some(partitionSpec.partitionColumns)) {\n+}\n \n-  override def partitionSpec(): PartitionSpec = partitionSpecFromHive\n+private[hive] object MetaStoreFileCatalog {\n+  /** Get the list of non-overalapping paths to list files in the for a metastore table */\n+  def getPaths(tableBasePath: Path, partitionSpec: PartitionSpec): Seq[Path] = {\n+    val basePathStr = tableBasePath.toUri.toString\n+    val partitionsOutsideBasePath = partitionSpec","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala","position":null,"original_position":38,"commit_id":"6b81f8f279ea4f57e02c40fcef050b7e15dbefaa","original_commit_id":"8ab243c76d51682439b76f959f518dd8abb233eb","user":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"body":"Oh, sorry. @tdas was trying to cc me.","created_at":"2016-06-21T16:53:32Z","updated_at":"2016-06-21T16:53:32Z","html_url":"https://github.com/apache/spark/pull/13022#discussion_r67907323","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/13022","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/67907323"},"html":{"href":"https://github.com/apache/spark/pull/13022#discussion_r67907323"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/13022"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13022","id":69470263,"html_url":"https://github.com/apache/spark/pull/13022","diff_url":"https://github.com/apache/spark/pull/13022.diff","patch_url":"https://github.com/apache/spark/pull/13022.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/13022","number":13022,"state":"closed","locked":false,"title":"[SPARK-15248][SQL] Make MetastoreFileCatalog consider directories from partition specs of a partitioned metastore table","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nTable partitions can be added with locations different from default warehouse location of a hive table.\r\n`CREATE TABLE parquetTable (a int) PARTITIONED BY (b int) STORED AS parquet `\r\n`ALTER TABLE parquetTable ADD PARTITION (b=1) LOCATION '/path/1'`\r\nQuerying such a table throws error as the MetastoreFileCatalog does not list the added partition directory, it only lists the default base location.\r\n\r\n```\r\n[info] - SPARK-15248: explicitly added partitions should be readable *** FAILED *** (1 second, 8 milliseconds)\r\n[info]   java.util.NoSuchElementException: key not found: file:/Users/tdas/Projects/Spark/spark2/target/tmp/spark-b39ad224-c5d1-4966-8981-fb45a2066d61/partition\r\n[info]   at scala.collection.MapLike$class.default(MapLike.scala:228)\r\n[info]   at scala.collection.AbstractMap.default(Map.scala:59)\r\n[info]   at scala.collection.MapLike$class.apply(MapLike.scala:141)\r\n[info]   at scala.collection.AbstractMap.apply(Map.scala:59)\r\n[info]   at org.apache.spark.sql.execution.datasources.PartitioningAwareFileCatalog$$anonfun$listFiles$1.apply(PartitioningAwareFileCatalog.scala:59)\r\n[info]   at org.apache.spark.sql.execution.datasources.PartitioningAwareFileCatalog$$anonfun$listFiles$1.apply(PartitioningAwareFileCatalog.scala:55)\r\n[info]   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)\r\n[info]   at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)\r\n[info]   at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)\r\n[info]   at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)\r\n[info]   at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)\r\n[info]   at scala.collection.AbstractTraversable.map(Traversable.scala:104)\r\n[info]   at org.apache.spark.sql.execution.datasources.PartitioningAwareFileCatalog.listFiles(PartitioningAwareFileCatalog.scala:55)\r\n[info]   at org.apache.spark.sql.execution.datasources.FileSourceStrategy$.apply(FileSourceStrategy.scala:93)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:59)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:59)\r\n[info]   at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:434)\r\n[info]   at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:440)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner.plan(QueryPlanner.scala:60)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner.planLater(QueryPlanner.scala:55)\r\n[info]   at org.apache.spark.sql.execution.SparkStrategies$SpecialLimits$.apply(SparkStrategies.scala:55)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:59)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner$$anonfun$1.apply(QueryPlanner.scala:59)\r\n[info]   at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:434)\r\n[info]   at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:440)\r\n[info]   at org.apache.spark.sql.catalyst.planning.QueryPlanner.plan(QueryPlanner.scala:60)\r\n[info]   at org.apache.spark.sql.execution.QueryExecution.sparkPlan$lzycompute(QueryExecution.scala:77)\r\n[info]   at org.apache.spark.sql.execution.QueryExecution.sparkPlan(QueryExecution.scala:75)\r\n[info]   at org.apache.spark.sql.execution.QueryExecution.executedPlan$lzycompute(QueryExecution.scala:82)\r\n[info]   at org.apache.spark.sql.execution.QueryExecution.executedPlan(QueryExecution.scala:82)\r\n[info]   at org.apache.spark.sql.QueryTest.assertEmptyMissingInput(QueryTest.scala:330)\r\n[info]   at org.apache.spark.sql.QueryTest.checkAnswer(QueryTest.scala:146)\r\n[info]   at org.apache.spark.sql.QueryTest.checkAnswer(QueryTest.scala:159)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12$$anonfun$apply$mcV$sp$7$$anonfun$apply$mcV$sp$25.apply(parquetSuites.scala:554)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12$$anonfun$apply$mcV$sp$7$$anonfun$apply$mcV$sp$25.apply(parquetSuites.scala:535)\r\n[info]   at org.apache.spark.sql.test.SQLTestUtils$class.withTempDir(SQLTestUtils.scala:125)\r\n[info]   at org.apache.spark.sql.hive.ParquetPartitioningTest.withTempDir(parquetSuites.scala:726)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12$$anonfun$apply$mcV$sp$7.apply$mcV$sp(parquetSuites.scala:535)\r\n[info]   at org.apache.spark.sql.test.SQLTestUtils$class.withTable(SQLTestUtils.scala:166)\r\n[info]   at org.apache.spark.sql.hive.ParquetPartitioningTest.withTable(parquetSuites.scala:726)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12.apply$mcV$sp(parquetSuites.scala:534)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12.apply(parquetSuites.scala:534)\r\n[info]   at org.apache.spark.sql.hive.ParquetMetastoreSuite$$anonfun$12.apply(parquetSuites.scala:534)\r\n```\r\n\r\n\r\nThe solution in this PR to get the paths to list from the partition spec and not rely on the default table path alone. \r\n\r\n## How was this patch tested?\r\n\r\nunit tests.\r\n\r\n\r\n","created_at":"2016-05-10T08:57:14Z","updated_at":"2016-06-21T16:53:32Z","closed_at":"2016-05-11T19:39:29Z","merged_at":null,"merge_commit_sha":"00e55266b74972d8fad6fd31ab9d8163f86ee0dd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/13022/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/13022/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/13022/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/6b81f8f279ea4f57e02c40fcef050b7e15dbefaa","head":{"label":"tdas:SPARK-15248","ref":"SPARK-15248","sha":"6b81f8f279ea4f57e02c40fcef050b7e15dbefaa","user":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"repo":{"id":17603343,"name":"spark","full_name":"tdas/spark","owner":{"login":"tdas","id":663212,"avatar_url":"https://avatars.githubusercontent.com/u/663212?v=3","gravatar_id":"","url":"https://api.github.com/users/tdas","html_url":"https://github.com/tdas","followers_url":"https://api.github.com/users/tdas/followers","following_url":"https://api.github.com/users/tdas/following{/other_user}","gists_url":"https://api.github.com/users/tdas/gists{/gist_id}","starred_url":"https://api.github.com/users/tdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdas/subscriptions","organizations_url":"https://api.github.com/users/tdas/orgs","repos_url":"https://api.github.com/users/tdas/repos","events_url":"https://api.github.com/users/tdas/events{/privacy}","received_events_url":"https://api.github.com/users/tdas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdas/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/tdas/spark","forks_url":"https://api.github.com/repos/tdas/spark/forks","keys_url":"https://api.github.com/repos/tdas/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdas/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdas/spark/teams","hooks_url":"https://api.github.com/repos/tdas/spark/hooks","issue_events_url":"https://api.github.com/repos/tdas/spark/issues/events{/number}","events_url":"https://api.github.com/repos/tdas/spark/events","assignees_url":"https://api.github.com/repos/tdas/spark/assignees{/user}","branches_url":"https://api.github.com/repos/tdas/spark/branches{/branch}","tags_url":"https://api.github.com/repos/tdas/spark/tags","blobs_url":"https://api.github.com/repos/tdas/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdas/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdas/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdas/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdas/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/tdas/spark/languages","stargazers_url":"https://api.github.com/repos/tdas/spark/stargazers","contributors_url":"https://api.github.com/repos/tdas/spark/contributors","subscribers_url":"https://api.github.com/repos/tdas/spark/subscribers","subscription_url":"https://api.github.com/repos/tdas/spark/subscription","commits_url":"https://api.github.com/repos/tdas/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdas/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdas/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdas/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/tdas/spark/contents/{+path}","compare_url":"https://api.github.com/repos/tdas/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdas/spark/merges","archive_url":"https://api.github.com/repos/tdas/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdas/spark/downloads","issues_url":"https://api.github.com/repos/tdas/spark/issues{/number}","pulls_url":"https://api.github.com/repos/tdas/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/tdas/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/tdas/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdas/spark/labels{/name}","releases_url":"https://api.github.com/repos/tdas/spark/releases{/id}","deployments_url":"https://api.github.com/repos/tdas/spark/deployments","created_at":"2014-03-10T18:19:48Z","updated_at":"2016-03-15T03:03:38Z","pushed_at":"2016-06-20T12:10:31Z","git_url":"git://github.com/tdas/spark.git","ssh_url":"git@github.com:tdas/spark.git","clone_url":"https://github.com/tdas/spark.git","svn_url":"https://github.com/tdas/spark","homepage":null,"size":177627,"stargazers_count":2,"watchers_count":2,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"da02d006bbb5c4fe62abd5542b9fff7d1c58603c","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-21T16:34:13Z","pushed_at":"2016-06-21T16:38:13Z","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":491329,"stargazers_count":8996,"watchers_count":8996,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8356,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":383,"forks":8356,"open_issues":383,"watchers":8996,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/13022"},"html":{"href":"https://github.com/apache/spark/pull/13022"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/13022"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/13022/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/13022/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/13022/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/6b81f8f279ea4f57e02c40fcef050b7e15dbefaa"}}}}
{"actor":{"display_login":"yhuai"}}