{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/24148995","id":24148995,"diff_hunk":"@@ -207,13 +217,22 @@ class HadoopTableReader(\n    * If `filterOpt` is defined, then it will be used to filter files from `path`. These files are\n    * returned in a single, comma-separated string.\n    */\n-  private def applyFilterIfNeeded(path: Path, filterOpt: Option[PathFilter]): String = {\n-    filterOpt match {\n-      case Some(filter) =>\n-        val fs = path.getFileSystem(sc.hiveconf)\n-        val filteredFiles = fs.listStatus(path, filter).map(_.getPath.toString)\n-        filteredFiles.mkString(\",\")\n-      case None => path.toString\n+  private def applyFilterIfNeeded(path: Path, filterOpt: Option[PathFilter]): Option[String] = {\n+    val fs = path.getFileSystem(sc.hiveconf)\n+    if (fs.exists(path)) {","path":"sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala","position":176,"original_position":176,"commit_id":"d3a4d3c0b6b6f015f61a7d23b4401761f0b25a60","original_commit_id":"d3a4d3c0b6b6f015f61a7d23b4401761f0b25a60","user":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"body":"My concern is similar to what @marmbrus mentioned in #3981. It's pretty expensive to check each path in serial for tables with lots of partitions. Especially when the data reside on S3. Can we use `listStatus` or `globStatus` to retrieve all `FileStatus` objects under some path(s), and then do the filtering locally?","created_at":"2015-02-05T08:27:06Z","updated_at":"2015-02-05T08:27:06Z","html_url":"https://github.com/apache/spark/pull/4356#discussion_r24148995","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/4356","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/24148995"},"html":{"href":"https://github.com/apache/spark/pull/4356#discussion_r24148995"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/4356"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4356","id":28616690,"html_url":"https://github.com/apache/spark/pull/4356","diff_url":"https://github.com/apache/spark/pull/4356.diff","patch_url":"https://github.com/apache/spark/pull/4356.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/4356","number":4356,"state":"open","locked":false,"title":"[SPARK-5068] [SQL] Fix bug query data when path doesn't exist for HiveContext","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":"This is a follow up for #3907 & #3891 .\r\n\r\nHive actually support the not existed path(either table or partition path) by yielding an empty row, but Spark SQL will throws exception.\r\n\r\nIdeally, we need to check the path existence during the partition processing, however, the `InputFormat` always computes the file splits before that, hence exception will raised if the specified path doesn't exists. \r\n\r\nThis PR backs to the solution of #3891, and check the partition/table paths existence in spark plan generation. And of course we can move that logic into `HadoopRDD` if it support the non exist path in the future.\r\n\r\n@jeanlyn, @marmbrus, @srowen ","created_at":"2015-02-04T06:43:47Z","updated_at":"2015-02-05T08:27:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d18fcaec0651c23acf3e740685eb28426473f38","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/4356/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/4356/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/4356/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/d3a4d3c0b6b6f015f61a7d23b4401761f0b25a60","head":{"label":"chenghao-intel:partition","ref":"partition","sha":"d3a4d3c0b6b6f015f61a7d23b4401761f0b25a60","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},"repo":{"id":18098468,"name":"spark","full_name":"chenghao-intel/spark","owner":{"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},"private":false,"html_url":"https://github.com/chenghao-intel/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/chenghao-intel/spark","forks_url":"https://api.github.com/repos/chenghao-intel/spark/forks","keys_url":"https://api.github.com/repos/chenghao-intel/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chenghao-intel/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chenghao-intel/spark/teams","hooks_url":"https://api.github.com/repos/chenghao-intel/spark/hooks","issue_events_url":"https://api.github.com/repos/chenghao-intel/spark/issues/events{/number}","events_url":"https://api.github.com/repos/chenghao-intel/spark/events","assignees_url":"https://api.github.com/repos/chenghao-intel/spark/assignees{/user}","branches_url":"https://api.github.com/repos/chenghao-intel/spark/branches{/branch}","tags_url":"https://api.github.com/repos/chenghao-intel/spark/tags","blobs_url":"https://api.github.com/repos/chenghao-intel/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chenghao-intel/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chenghao-intel/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/chenghao-intel/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chenghao-intel/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/chenghao-intel/spark/languages","stargazers_url":"https://api.github.com/repos/chenghao-intel/spark/stargazers","contributors_url":"https://api.github.com/repos/chenghao-intel/spark/contributors","subscribers_url":"https://api.github.com/repos/chenghao-intel/spark/subscribers","subscription_url":"https://api.github.com/repos/chenghao-intel/spark/subscription","commits_url":"https://api.github.com/repos/chenghao-intel/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/chenghao-intel/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/chenghao-intel/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/chenghao-intel/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/chenghao-intel/spark/contents/{+path}","compare_url":"https://api.github.com/repos/chenghao-intel/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chenghao-intel/spark/merges","archive_url":"https://api.github.com/repos/chenghao-intel/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chenghao-intel/spark/downloads","issues_url":"https://api.github.com/repos/chenghao-intel/spark/issues{/number}","pulls_url":"https://api.github.com/repos/chenghao-intel/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/chenghao-intel/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/chenghao-intel/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chenghao-intel/spark/labels{/name}","releases_url":"https://api.github.com/repos/chenghao-intel/spark/releases{/id}","created_at":"2014-03-25T11:52:04Z","updated_at":"2014-06-25T04:24:49Z","pushed_at":"2015-02-05T03:09:15Z","git_url":"git://github.com/chenghao-intel/spark.git","ssh_url":"git@github.com:chenghao-intel/spark.git","clone_url":"https://github.com/chenghao-intel/spark.git","svn_url":"https://github.com/chenghao-intel/spark","homepage":null,"size":88929,"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":"e380d2d46c92b319eafe30974ac7c1509081fca4","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-02-05T08:22:09Z","pushed_at":"2015-02-05T07:58:36Z","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":1204611,"stargazers_count":2775,"watchers_count":2775,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2435,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":294,"forks":2435,"open_issues":294,"watchers":2775,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/4356"},"html":{"href":"https://github.com/apache/spark/pull/4356"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/4356"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/4356/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/4356/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/4356/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/d3a4d3c0b6b6f015f61a7d23b4401761f0b25a60"}}}}