{"action":"created","comment":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/23105893","id":23105893,"diff_hunk":"@@ -40,8 +46,40 @@ case class AvroRelation(location: String)(@transient val sqlContext: SQLContext)\n     convertedSchema\n   }\n \n+  // There are several properties of Avro that we have to account for in this method:\n+  // 1) Avro uses Utf8 strings, so we want to convert them to java.lang.String for SparkSQL,\n+  //    including making the appropriate recursive calls.\n+  // 2) Avro map keys are always strings, so we don't need to recurse on them when processing maps.\n+  // 3) Byte arrays and ByteBuffers are reused by Avro, so we must copy them out.\n+  def convertToSparkSQL(obj: Any): Any = {\n+    obj match {\n+      case u: Utf8 => u.toString\n+      case m: Map[Any, Any] => m.map(x => (x._1.toString, convertToSparkSQL(x._2)))\n+      case a: GenericData.Array[Any] => {\n+        val ar = new Array[Any](a.size)\n+        var idx = 0\n+        while (idx < a.size) {\n+          ar(idx) = convertToSparkSQL(a(0))","path":"src/main/scala/com/databricks/spark/avro/AvroRelation.scala","position":47,"original_position":47,"commit_id":"f09af359078506b2c7c694bd7463ac6276be4941","original_commit_id":"f09af359078506b2c7c694bd7463ac6276be4941","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":"should this be a(idx)? Also, consider more descriptive names (something like a -> avroArray; ar -> javaArray)","created_at":"2015-01-16T20:08:40Z","updated_at":"2015-01-16T20:08:40Z","html_url":"https://github.com/databricks/spark-avro/pull/12#discussion_r23105893","pull_request_url":"https://api.github.com/repos/databricks/spark-avro/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/comments/23105893"},"html":{"href":"https://github.com/databricks/spark-avro/pull/12#discussion_r23105893"},"pull_request":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/databricks/spark-avro/pulls/12","id":27402722,"html_url":"https://github.com/databricks/spark-avro/pull/12","diff_url":"https://github.com/databricks/spark-avro/pull/12.diff","patch_url":"https://github.com/databricks/spark-avro/pull/12.patch","issue_url":"https://api.github.com/repos/databricks/spark-avro/issues/12","number":12,"state":"open","locked":false,"title":"Adding support for the new datatypes","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":"Adds support for new datatypes. I added a test avro file and wrote a test to ensure stuff works as expected. If you think it's a good idea, I can also add files that I used to generate test.avro, in case someone needs to update it later.\r\n\r\ncc @aarondav @marmbrus ","created_at":"2015-01-15T02:52:27Z","updated_at":"2015-01-16T20:08:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a22870735f95dbf665e0d8cc63339116274f0f64","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/databricks/spark-avro/pulls/12/commits","review_comments_url":"https://api.github.com/repos/databricks/spark-avro/pulls/12/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/12/comments","statuses_url":"https://api.github.com/repos/databricks/spark-avro/statuses/f09af359078506b2c7c694bd7463ac6276be4941","head":{"label":"vlyubin:newDatatypes","ref":"newDatatypes","sha":"f09af359078506b2c7c694bd7463ac6276be4941","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-01-14T07:15:03Z","pushed_at":"2015-01-15T19:59:24Z","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":430,"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":"5390f78cff7cab9c0516e7df336c5428b92dc938","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-01-14T07:15:12Z","pushed_at":"2014-12-25T06:12:09Z","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":430,"stargazers_count":26,"watchers_count":26,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":6,"forks":18,"open_issues":6,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/12"},"html":{"href":"https://github.com/databricks/spark-avro/pull/12"},"issue":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/12"},"comments":{"href":"https://api.github.com/repos/databricks/spark-avro/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/databricks/spark-avro/pulls/12/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/12/commits"},"statuses":{"href":"https://api.github.com/repos/databricks/spark-avro/statuses/f09af359078506b2c7c694bd7463ac6276be4941"}}}}