{"action":"created","comment":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/24109092","id":24109092,"diff_hunk":"@@ -74,6 +75,11 @@ case class AvroRelation(location: String)(@transient val sqlContext: SQLContext)\n   private def newReader() = {\n     val path = new Path(location)\n     val fs = FileSystem.get(path.toUri, sqlContext.sparkContext.hadoopConfiguration)\n+\n+    if (fs.globStatus(path) == null) {","path":"src/main/scala/com/databricks/spark/avro/AvroRelation.scala","position":13,"original_position":13,"commit_id":"4fa589efa64554ff136bffa13d990176ec7114aa","original_commit_id":"4fa589efa64554ff136bffa13d990176ec7114aa","user":{"login":"aarondav","id":1400247,"avatar_url":"https://avatars.githubusercontent.com/u/1400247?v=3","gravatar_id":"","url":"https://api.github.com/users/aarondav","html_url":"https://github.com/aarondav","followers_url":"https://api.github.com/users/aarondav/followers","following_url":"https://api.github.com/users/aarondav/following{/other_user}","gists_url":"https://api.github.com/users/aarondav/gists{/gist_id}","starred_url":"https://api.github.com/users/aarondav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarondav/subscriptions","organizations_url":"https://api.github.com/users/aarondav/orgs","repos_url":"https://api.github.com/users/aarondav/repos","events_url":"https://api.github.com/users/aarondav/events{/privacy}","received_events_url":"https://api.github.com/users/aarondav/received_events","type":"User","site_admin":false},"body":"Let's add a unit test for this. Also, globStatus may be expensive, so let's just reuse one call.","created_at":"2015-02-04T19:02:43Z","updated_at":"2015-02-04T19:02:43Z","html_url":"https://github.com/databricks/spark-avro/pull/23#discussion_r24109092","pull_request_url":"https://api.github.com/repos/databricks/spark-avro/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/24109092"},"html":{"href":"https://github.com/databricks/spark-avro/pull/23#discussion_r24109092"},"pull_request":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/23","id":28662409,"html_url":"https://github.com/databricks/spark-avro/pull/23","diff_url":"https://github.com/databricks/spark-avro/pull/23.diff","patch_url":"https://github.com/databricks/spark-avro/pull/23.patch","issue_url":"https://api.github.com/repos/databricks/spark-avro/issues/23","number":23,"state":"open","locked":false,"title":"Throw better error when invalid path is provided","user":{"login":"vlyubin","id":3303322,"avatar_url":"https://avatars.githubusercontent.com/u/3303322?v=3","gravatar_id":"","url":"https://api.github.com/users/vlyubin","html_url":"https://github.com/vlyubin","followers_url":"https://api.github.com/users/vlyubin/followers","following_url":"https://api.github.com/users/vlyubin/following{/other_user}","gists_url":"https://api.github.com/users/vlyubin/gists{/gist_id}","starred_url":"https://api.github.com/users/vlyubin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlyubin/subscriptions","organizations_url":"https://api.github.com/users/vlyubin/orgs","repos_url":"https://api.github.com/users/vlyubin/repos","events_url":"https://api.github.com/users/vlyubin/events{/privacy}","received_events_url":"https://api.github.com/users/vlyubin/received_events","type":"User","site_admin":false},"body":"The PR for globbed paths made errors for invalid paths very unclear. Here is the exception that you get when invalid path is provided:\r\n\r\n```scala> val students = sqlContext.avroFile(\"/wut/is/this/invalidName.avro\")\r\njava.lang.NullPointerException\r\n\tat scala.collection.mutable.ArrayOps$ofRef$.length$extension(ArrayOps.scala:114)\r\n\tat scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:114)\r\n\tat scala.collection.IndexedSeqLike$class.iterator(IndexedSeqLike.scala:91)```\r\n\r\nWhich is not very helpful. This PR adds explicit error message for invalid path:\r\n\r\n```scala> val students = sqlContext.avroFile(\"/wut/is/this/invalidName.avro\")\r\njava.io.FileNotFoundException: The path you've provided (/wut/da/fu.avro) is invalid.\r\n\tat com.databricks.spark.avro.AvroRelation.newReader(AvroRelation.scala:78)\r\n\tat com.databricks.spark.avro.AvroRelation.<init>(AvroRelation.scala:44)```","created_at":"2015-02-04T18:29:01Z","updated_at":"2015-02-04T19:02:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6b0722f400a34249e29f5cf875110a58a4c2f9a","assignee":{"login":"aarondav","id":1400247,"avatar_url":"https://avatars.githubusercontent.com/u/1400247?v=3","gravatar_id":"","url":"https://api.github.com/users/aarondav","html_url":"https://github.com/aarondav","followers_url":"https://api.github.com/users/aarondav/followers","following_url":"https://api.github.com/users/aarondav/following{/other_user}","gists_url":"https://api.github.com/users/aarondav/gists{/gist_id}","starred_url":"https://api.github.com/users/aarondav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarondav/subscriptions","organizations_url":"https://api.github.com/users/aarondav/orgs","repos_url":"https://api.github.com/users/aarondav/repos","events_url":"https://api.github.com/users/aarondav/events{/privacy}","received_events_url":"https://api.github.com/users/aarondav/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/databricks/spark-avro/pulls/23/commits","review_comments_url":"https://api.github.com/repos/databricks/spark-avro/pulls/23/comments","review_comment_url":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/{number}","comments_url":"https://api.github.com/repos/databricks/spark-avro/issues/23/comments","statuses_url":"https://api.github.com/repos/databricks/spark-avro/statuses/4fa589efa64554ff136bffa13d990176ec7114aa","head":{"label":"vlyubin:betterErrors","ref":"betterErrors","sha":"4fa589efa64554ff136bffa13d990176ec7114aa","user":{"login":"vlyubin","id":3303322,"avatar_url":"https://avatars.githubusercontent.com/u/3303322?v=3","gravatar_id":"","url":"https://api.github.com/users/vlyubin","html_url":"https://github.com/vlyubin","followers_url":"https://api.github.com/users/vlyubin/followers","following_url":"https://api.github.com/users/vlyubin/following{/other_user}","gists_url":"https://api.github.com/users/vlyubin/gists{/gist_id}","starred_url":"https://api.github.com/users/vlyubin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlyubin/subscriptions","organizations_url":"https://api.github.com/users/vlyubin/orgs","repos_url":"https://api.github.com/users/vlyubin/repos","events_url":"https://api.github.com/users/vlyubin/events{/privacy}","received_events_url":"https://api.github.com/users/vlyubin/received_events","type":"User","site_admin":false},"repo":{"id":29206505,"name":"spark-avro","full_name":"vlyubin/spark-avro","owner":{"login":"vlyubin","id":3303322,"avatar_url":"https://avatars.githubusercontent.com/u/3303322?v=3","gravatar_id":"","url":"https://api.github.com/users/vlyubin","html_url":"https://github.com/vlyubin","followers_url":"https://api.github.com/users/vlyubin/followers","following_url":"https://api.github.com/users/vlyubin/following{/other_user}","gists_url":"https://api.github.com/users/vlyubin/gists{/gist_id}","starred_url":"https://api.github.com/users/vlyubin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlyubin/subscriptions","organizations_url":"https://api.github.com/users/vlyubin/orgs","repos_url":"https://api.github.com/users/vlyubin/repos","events_url":"https://api.github.com/users/vlyubin/events{/privacy}","received_events_url":"https://api.github.com/users/vlyubin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vlyubin/spark-avro","description":"Integration utilities for using Spark with Apache Avro data","fork":true,"url":"https://api.github.com/repos/vlyubin/spark-avro","forks_url":"https://api.github.com/repos/vlyubin/spark-avro/forks","keys_url":"https://api.github.com/repos/vlyubin/spark-avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vlyubin/spark-avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vlyubin/spark-avro/teams","hooks_url":"https://api.github.com/repos/vlyubin/spark-avro/hooks","issue_events_url":"https://api.github.com/repos/vlyubin/spark-avro/issues/events{/number}","events_url":"https://api.github.com/repos/vlyubin/spark-avro/events","assignees_url":"https://api.github.com/repos/vlyubin/spark-avro/assignees{/user}","branches_url":"https://api.github.com/repos/vlyubin/spark-avro/branches{/branch}","tags_url":"https://api.github.com/repos/vlyubin/spark-avro/tags","blobs_url":"https://api.github.com/repos/vlyubin/spark-avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vlyubin/spark-avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vlyubin/spark-avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/vlyubin/spark-avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vlyubin/spark-avro/statuses/{sha}","languages_url":"https://api.github.com/repos/vlyubin/spark-avro/languages","stargazers_url":"https://api.github.com/repos/vlyubin/spark-avro/stargazers","contributors_url":"https://api.github.com/repos/vlyubin/spark-avro/contributors","subscribers_url":"https://api.github.com/repos/vlyubin/spark-avro/subscribers","subscription_url":"https://api.github.com/repos/vlyubin/spark-avro/subscription","commits_url":"https://api.github.com/repos/vlyubin/spark-avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/vlyubin/spark-avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/vlyubin/spark-avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/vlyubin/spark-avro/issues/comments/{number}","contents_url":"https://api.github.com/repos/vlyubin/spark-avro/contents/{+path}","compare_url":"https://api.github.com/repos/vlyubin/spark-avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vlyubin/spark-avro/merges","archive_url":"https://api.github.com/repos/vlyubin/spark-avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vlyubin/spark-avro/downloads","issues_url":"https://api.github.com/repos/vlyubin/spark-avro/issues{/number}","pulls_url":"https://api.github.com/repos/vlyubin/spark-avro/pulls{/number}","milestones_url":"https://api.github.com/repos/vlyubin/spark-avro/milestones{/number}","notifications_url":"https://api.github.com/repos/vlyubin/spark-avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vlyubin/spark-avro/labels{/name}","releases_url":"https://api.github.com/repos/vlyubin/spark-avro/releases{/id}","created_at":"2015-01-13T19:19:05Z","updated_at":"2015-02-03T20:12:03Z","pushed_at":"2015-02-04T18:56:19Z","git_url":"git://github.com/vlyubin/spark-avro.git","ssh_url":"git@github.com:vlyubin/spark-avro.git","clone_url":"https://github.com/vlyubin/spark-avro.git","svn_url":"https://github.com/vlyubin/spark-avro","homepage":null,"size":336,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"databricks:master","ref":"master","sha":"4080b5214cd113b2c45c3f6134884c8fd876382f","user":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"repo":{"id":24648767,"name":"spark-avro","full_name":"databricks/spark-avro","owner":{"login":"databricks","id":4998052,"avatar_url":"https://avatars.githubusercontent.com/u/4998052?v=3","gravatar_id":"","url":"https://api.github.com/users/databricks","html_url":"https://github.com/databricks","followers_url":"https://api.github.com/users/databricks/followers","following_url":"https://api.github.com/users/databricks/following{/other_user}","gists_url":"https://api.github.com/users/databricks/gists{/gist_id}","starred_url":"https://api.github.com/users/databricks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/databricks/subscriptions","organizations_url":"https://api.github.com/users/databricks/orgs","repos_url":"https://api.github.com/users/databricks/repos","events_url":"https://api.github.com/users/databricks/events{/privacy}","received_events_url":"https://api.github.com/users/databricks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/databricks/spark-avro","description":"Integration utilities for using Spark with Apache Avro data","fork":false,"url":"https://api.github.com/repos/databricks/spark-avro","forks_url":"https://api.github.com/repos/databricks/spark-avro/forks","keys_url":"https://api.github.com/repos/databricks/spark-avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/databricks/spark-avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/databricks/spark-avro/teams","hooks_url":"https://api.github.com/repos/databricks/spark-avro/hooks","issue_events_url":"https://api.github.com/repos/databricks/spark-avro/issues/events{/number}","events_url":"https://api.github.com/repos/databricks/spark-avro/events","assignees_url":"https://api.github.com/repos/databricks/spark-avro/assignees{/user}","branches_url":"https://api.github.com/repos/databricks/spark-avro/branches{/branch}","tags_url":"https://api.github.com/repos/databricks/spark-avro/tags","blobs_url":"https://api.github.com/repos/databricks/spark-avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/databricks/spark-avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/databricks/spark-avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/databricks/spark-avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/databricks/spark-avro/statuses/{sha}","languages_url":"https://api.github.com/repos/databricks/spark-avro/languages","stargazers_url":"https://api.github.com/repos/databricks/spark-avro/stargazers","contributors_url":"https://api.github.com/repos/databricks/spark-avro/contributors","subscribers_url":"https://api.github.com/repos/databricks/spark-avro/subscribers","subscription_url":"https://api.github.com/repos/databricks/spark-avro/subscription","commits_url":"https://api.github.com/repos/databricks/spark-avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/databricks/spark-avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/databricks/spark-avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/databricks/spark-avro/issues/comments/{number}","contents_url":"https://api.github.com/repos/databricks/spark-avro/contents/{+path}","compare_url":"https://api.github.com/repos/databricks/spark-avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/databricks/spark-avro/merges","archive_url":"https://api.github.com/repos/databricks/spark-avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/databricks/spark-avro/downloads","issues_url":"https://api.github.com/repos/databricks/spark-avro/issues{/number}","pulls_url":"https://api.github.com/repos/databricks/spark-avro/pulls{/number}","milestones_url":"https://api.github.com/repos/databricks/spark-avro/milestones{/number}","notifications_url":"https://api.github.com/repos/databricks/spark-avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/databricks/spark-avro/labels{/name}","releases_url":"https://api.github.com/repos/databricks/spark-avro/releases{/id}","created_at":"2014-09-30T17:50:58Z","updated_at":"2015-02-03T19:59:39Z","pushed_at":"2015-02-03T19:59:39Z","git_url":"git://github.com/databricks/spark-avro.git","ssh_url":"git@github.com:databricks/spark-avro.git","clone_url":"https://github.com/databricks/spark-avro.git","svn_url":"https://github.com/databricks/spark-avro","homepage":null,"size":502,"stargazers_count":30,"watchers_count":30,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":4,"forks":21,"open_issues":4,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/23"},"html":{"href":"https://github.com/databricks/spark-avro/pull/23"},"issue":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/23"},"comments":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/databricks/spark-avro/statuses/4fa589efa64554ff136bffa13d990176ec7114aa"}}}}