{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/27782363","id":27782363,"diff_hunk":"@@ -142,7 +142,46 @@ class HadoopTableReader(\n       partitionToDeserializer: Map[HivePartition,\n       Class[_ <: Deserializer]],\n       filterOpt: Option[PathFilter]): RDD[Row] = {\n-    val hivePartitionRDDs = partitionToDeserializer.map { case (partition, partDeserializer) =>\n+        \n+    // SPARK-5068:get FileStatus and do the filtering locally when the path is not exists\n+    def verifyPartitionPath(\n+        partitionToDeserializer: Map[HivePartition, Class[_ <: Deserializer]]):\n+        Map[HivePartition, Class[_ <: Deserializer]] = {\n+      if (!sc.getConf(\"spark.sql.hive.verifyPartitionPath\", \"true\").toBoolean) {\n+        partitionToDeserializer\n+      } else {\n+        var existPathSet = collection.mutable.Set[String]()\n+        var pathPatternSet = collection.mutable.Set[String]()\n+        partitionToDeserializer.filter {\n+          case (partition, partDeserializer) =>\n+            def updateExistPathSetByPathPattern(pathPatternStr: String) {\n+              val pathPattern = new Path(pathPatternStr)\n+              val fs = pathPattern.getFileSystem(sc.hiveconf)\n+              val matches = fs.globStatus(pathPattern)\n+              matches.map(fileStatus => existPathSet += fileStatus.getPath.toString)\n+            }\n+            // convert  /demo/data/year/month/day  to  /demo/data/**/**/**/","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala","position":23,"original_position":23,"commit_id":"e1d638678c5f5b44a201d3d37c70683c033f6ed0","original_commit_id":"e1d638678c5f5b44a201d3d37c70683c033f6ed0","user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"body":"to `/demo/data/*/*/*/`?","created_at":"2015-04-06T01:32:10Z","updated_at":"2015-04-06T01:32:10Z","html_url":"https://github.com/apache/spark/pull/5059#discussion_r27782363","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/5059","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/27782363"},"html":{"href":"https://github.com/apache/spark/pull/5059#discussion_r27782363"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/5059"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/5059","id":31304771,"html_url":"https://github.com/apache/spark/pull/5059","diff_url":"https://github.com/apache/spark/pull/5059.diff","patch_url":"https://github.com/apache/spark/pull/5059.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/5059","number":5059,"state":"open","locked":false,"title":"[Spark-5068][SQL]Fix bug query data when path doesn't exist for HiveContext","user":{"login":"lazyman500","id":2443477,"avatar_url":"https://avatars.githubusercontent.com/u/2443477?v=3","gravatar_id":"","url":"https://api.github.com/users/lazyman500","html_url":"https://github.com/lazyman500","followers_url":"https://api.github.com/users/lazyman500/followers","following_url":"https://api.github.com/users/lazyman500/following{/other_user}","gists_url":"https://api.github.com/users/lazyman500/gists{/gist_id}","starred_url":"https://api.github.com/users/lazyman500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazyman500/subscriptions","organizations_url":"https://api.github.com/users/lazyman500/orgs","repos_url":"https://api.github.com/users/lazyman500/repos","events_url":"https://api.github.com/users/lazyman500/events{/privacy}","received_events_url":"https://api.github.com/users/lazyman500/received_events","type":"User","site_admin":false},"body":"This PR follow up PR #3907 & #3891 & #4356.\r\nAccording to  @marmbrus  @liancheng 's comments, I try to use fs.globStatus to retrieve all FileStatus objects under path(s), and then do the filtering locally.\r\n\r\n[1]. get pathPattern by path, and put it into pathPatternSet. (hdfs://cluster/user/demo/2016/08/12 -> hdfs://cluster/user/demo/*/*/*)\r\n[2]. retrieve all FileStatus objects ,and cache them by undating existPathSet.\r\n[3]. do the filtering locally\r\n[4]. if we have new pathPattern,do 1,2 step again. (external table maybe have more than one partition pathPattern)   \r\n\r\n@chenghao-intel @jeanlyn","created_at":"2015-03-17T03:28:44Z","updated_at":"2015-04-06T01:32:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e270e8b2c76488b0eab313096914caf947c4d53","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/5059/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/5059/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/5059/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/e1d638678c5f5b44a201d3d37c70683c033f6ed0","head":{"label":"lazyman500:SPARK-5068","ref":"SPARK-5068","sha":"e1d638678c5f5b44a201d3d37c70683c033f6ed0","user":{"login":"lazyman500","id":2443477,"avatar_url":"https://avatars.githubusercontent.com/u/2443477?v=3","gravatar_id":"","url":"https://api.github.com/users/lazyman500","html_url":"https://github.com/lazyman500","followers_url":"https://api.github.com/users/lazyman500/followers","following_url":"https://api.github.com/users/lazyman500/following{/other_user}","gists_url":"https://api.github.com/users/lazyman500/gists{/gist_id}","starred_url":"https://api.github.com/users/lazyman500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazyman500/subscriptions","organizations_url":"https://api.github.com/users/lazyman500/orgs","repos_url":"https://api.github.com/users/lazyman500/repos","events_url":"https://api.github.com/users/lazyman500/events{/privacy}","received_events_url":"https://api.github.com/users/lazyman500/received_events","type":"User","site_admin":false},"repo":{"id":30189405,"name":"spark","full_name":"lazyman500/spark","owner":{"login":"lazyman500","id":2443477,"avatar_url":"https://avatars.githubusercontent.com/u/2443477?v=3","gravatar_id":"","url":"https://api.github.com/users/lazyman500","html_url":"https://github.com/lazyman500","followers_url":"https://api.github.com/users/lazyman500/followers","following_url":"https://api.github.com/users/lazyman500/following{/other_user}","gists_url":"https://api.github.com/users/lazyman500/gists{/gist_id}","starred_url":"https://api.github.com/users/lazyman500/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazyman500/subscriptions","organizations_url":"https://api.github.com/users/lazyman500/orgs","repos_url":"https://api.github.com/users/lazyman500/repos","events_url":"https://api.github.com/users/lazyman500/events{/privacy}","received_events_url":"https://api.github.com/users/lazyman500/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lazyman500/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/lazyman500/spark","forks_url":"https://api.github.com/repos/lazyman500/spark/forks","keys_url":"https://api.github.com/repos/lazyman500/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lazyman500/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lazyman500/spark/teams","hooks_url":"https://api.github.com/repos/lazyman500/spark/hooks","issue_events_url":"https://api.github.com/repos/lazyman500/spark/issues/events{/number}","events_url":"https://api.github.com/repos/lazyman500/spark/events","assignees_url":"https://api.github.com/repos/lazyman500/spark/assignees{/user}","branches_url":"https://api.github.com/repos/lazyman500/spark/branches{/branch}","tags_url":"https://api.github.com/repos/lazyman500/spark/tags","blobs_url":"https://api.github.com/repos/lazyman500/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lazyman500/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lazyman500/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/lazyman500/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lazyman500/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/lazyman500/spark/languages","stargazers_url":"https://api.github.com/repos/lazyman500/spark/stargazers","contributors_url":"https://api.github.com/repos/lazyman500/spark/contributors","subscribers_url":"https://api.github.com/repos/lazyman500/spark/subscribers","subscription_url":"https://api.github.com/repos/lazyman500/spark/subscription","commits_url":"https://api.github.com/repos/lazyman500/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/lazyman500/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/lazyman500/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/lazyman500/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/lazyman500/spark/contents/{+path}","compare_url":"https://api.github.com/repos/lazyman500/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lazyman500/spark/merges","archive_url":"https://api.github.com/repos/lazyman500/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lazyman500/spark/downloads","issues_url":"https://api.github.com/repos/lazyman500/spark/issues{/number}","pulls_url":"https://api.github.com/repos/lazyman500/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/lazyman500/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/lazyman500/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lazyman500/spark/labels{/name}","releases_url":"https://api.github.com/repos/lazyman500/spark/releases{/id}","created_at":"2015-02-02T13:58:22Z","updated_at":"2015-03-16T09:05:31Z","pushed_at":"2015-04-03T08:44:17Z","git_url":"git://github.com/lazyman500/spark.git","ssh_url":"git@github.com:lazyman500/spark.git","clone_url":"https://github.com/lazyman500/spark.git","svn_url":"https://github.com/lazyman500/spark","homepage":null,"size":96595,"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":"e3f315ac358dfe4f5b9705c3eac76e8b1e24f82a","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-04-05T23:13:41Z","pushed_at":"2015-04-06T00:34:02Z","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":1472423,"stargazers_count":3503,"watchers_count":3503,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3010,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":314,"forks":3010,"open_issues":314,"watchers":3503,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/5059"},"html":{"href":"https://github.com/apache/spark/pull/5059"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/5059"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/5059/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/5059/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/5059/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/e1d638678c5f5b44a201d3d37c70683c033f6ed0"}}}}