{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/68578656","id":68578656,"diff_hunk":"@@ -427,8 +427,12 @@ case class MapObjects private(\n       case _ => \"\"\n     }\n \n+    val inputDataType = inputData.dataType match {\n+      case p: PythonUserDefinedType => p.sqlType","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala","position":5,"original_position":5,"commit_id":"a0b81ba448018200eb8947bc496d8f07d87a64b8","original_commit_id":"d22dca85f53d60c3b15c37c45d3e85171beeea85","user":{"login":"viirya","id":68855,"avatar_url":"https://avatars.githubusercontent.com/u/68855?v=3","gravatar_id":"","url":"https://api.github.com/users/viirya","html_url":"https://github.com/viirya","followers_url":"https://api.github.com/users/viirya/followers","following_url":"https://api.github.com/users/viirya/following{/other_user}","gists_url":"https://api.github.com/users/viirya/gists{/gist_id}","starred_url":"https://api.github.com/users/viirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viirya/subscriptions","organizations_url":"https://api.github.com/users/viirya/orgs","repos_url":"https://api.github.com/users/viirya/repos","events_url":"https://api.github.com/users/viirya/events{/privacy}","received_events_url":"https://api.github.com/users/viirya/received_events","type":"User","site_admin":false},"body":"ok. let me check it.","created_at":"2016-06-27T13:47:55Z","updated_at":"2016-06-27T13:47:55Z","html_url":"https://github.com/apache/spark/pull/13778#discussion_r68578656","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/13778","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/68578656"},"html":{"href":"https://github.com/apache/spark/pull/13778#discussion_r68578656"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/13778"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/13778","id":74396980,"html_url":"https://github.com/apache/spark/pull/13778","diff_url":"https://github.com/apache/spark/pull/13778.diff","patch_url":"https://github.com/apache/spark/pull/13778.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/13778","number":13778,"state":"open","locked":false,"title":"[SPARK-16062][SPARK-15989][SQL] Fix two bugs of Python-only UDTs","user":{"login":"viirya","id":68855,"avatar_url":"https://avatars.githubusercontent.com/u/68855?v=3","gravatar_id":"","url":"https://api.github.com/users/viirya","html_url":"https://github.com/viirya","followers_url":"https://api.github.com/users/viirya/followers","following_url":"https://api.github.com/users/viirya/following{/other_user}","gists_url":"https://api.github.com/users/viirya/gists{/gist_id}","starred_url":"https://api.github.com/users/viirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viirya/subscriptions","organizations_url":"https://api.github.com/users/viirya/orgs","repos_url":"https://api.github.com/users/viirya/repos","events_url":"https://api.github.com/users/viirya/events{/privacy}","received_events_url":"https://api.github.com/users/viirya/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nThere are two related bugs of Python-only UDTs. Because the test case of second one needs the first fix too. I put them into one PR. If it is not appropriate, please let me know.\r\n\r\n### First bug: When MapObjects works on Python-only UDTs\r\n\r\n`RowEncoder` will use `PythonUserDefinedType.sqlType` for its deserializer expression. If the sql type is `ArrayType`, we will have `MapObjects` working on it. But `MapObjects` doesn't consider `PythonUserDefinedType` as its input data type. It causes error like:\r\n\r\n    import pyspark.sql.group\r\n    from pyspark.sql.tests import PythonOnlyPoint, PythonOnlyUDT\r\n    from pyspark.sql.types import *\r\n\r\n    schema = StructType().add(\"key\", LongType()).add(\"val\", PythonOnlyUDT())\r\n    df = spark.createDataFrame([(i % 3, PythonOnlyPoint(float(i), float(i))) for i in range(10)], schema=schema)\r\n    df.show()\r\n\r\n    File \"/home/spark/python/lib/py4j-0.10.1-src.zip/py4j/protocol.py\", line 312, in get_return_value py4j.protocol.Py4JJavaError: An error occurred while calling o36.showString.\r\n    : java.lang.RuntimeException: Error while decoding: scala.MatchError: org.apache.spark.sql.types.PythonUserDefinedType@f4ceede8 (of class org.apache.spark.sql.types.PythonUserDefinedType)\r\n    ...\r\n\r\n### Second bug: When Python-only UDTs is the element type of ArrayType\r\n\r\n    import pyspark.sql.group\r\n    from pyspark.sql.tests import PythonOnlyPoint, PythonOnlyUDT\r\n    from pyspark.sql.types import *\r\n\r\n    schema = StructType().add(\"key\", LongType()).add(\"val\", ArrayType(PythonOnlyUDT()))\r\n    df = spark.createDataFrame([(i % 3, [PythonOnlyPoint(float(i), float(i))]) for i in range(10)], schema=schema)\r\n    df.show()\r\n\r\n## How was this patch tested?\r\nPySpark's sql tests.\r\n\r\n","created_at":"2016-06-20T06:57:15Z","updated_at":"2016-06-27T13:47:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ff734dd3e8170776a251baaa2ade4675a13bff5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/13778/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/13778/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/13778/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/a0b81ba448018200eb8947bc496d8f07d87a64b8","head":{"label":"viirya:fix-pyudt","ref":"fix-pyudt","sha":"a0b81ba448018200eb8947bc496d8f07d87a64b8","user":{"login":"viirya","id":68855,"avatar_url":"https://avatars.githubusercontent.com/u/68855?v=3","gravatar_id":"","url":"https://api.github.com/users/viirya","html_url":"https://github.com/viirya","followers_url":"https://api.github.com/users/viirya/followers","following_url":"https://api.github.com/users/viirya/following{/other_user}","gists_url":"https://api.github.com/users/viirya/gists{/gist_id}","starred_url":"https://api.github.com/users/viirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viirya/subscriptions","organizations_url":"https://api.github.com/users/viirya/orgs","repos_url":"https://api.github.com/users/viirya/repos","events_url":"https://api.github.com/users/viirya/events{/privacy}","received_events_url":"https://api.github.com/users/viirya/received_events","type":"User","site_admin":false},"repo":{"id":21467907,"name":"spark-1","full_name":"viirya/spark-1","owner":{"login":"viirya","id":68855,"avatar_url":"https://avatars.githubusercontent.com/u/68855?v=3","gravatar_id":"","url":"https://api.github.com/users/viirya","html_url":"https://github.com/viirya","followers_url":"https://api.github.com/users/viirya/followers","following_url":"https://api.github.com/users/viirya/following{/other_user}","gists_url":"https://api.github.com/users/viirya/gists{/gist_id}","starred_url":"https://api.github.com/users/viirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viirya/subscriptions","organizations_url":"https://api.github.com/users/viirya/orgs","repos_url":"https://api.github.com/users/viirya/repos","events_url":"https://api.github.com/users/viirya/events{/privacy}","received_events_url":"https://api.github.com/users/viirya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/viirya/spark-1","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/viirya/spark-1","forks_url":"https://api.github.com/repos/viirya/spark-1/forks","keys_url":"https://api.github.com/repos/viirya/spark-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/viirya/spark-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/viirya/spark-1/teams","hooks_url":"https://api.github.com/repos/viirya/spark-1/hooks","issue_events_url":"https://api.github.com/repos/viirya/spark-1/issues/events{/number}","events_url":"https://api.github.com/repos/viirya/spark-1/events","assignees_url":"https://api.github.com/repos/viirya/spark-1/assignees{/user}","branches_url":"https://api.github.com/repos/viirya/spark-1/branches{/branch}","tags_url":"https://api.github.com/repos/viirya/spark-1/tags","blobs_url":"https://api.github.com/repos/viirya/spark-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/viirya/spark-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/viirya/spark-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/viirya/spark-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/viirya/spark-1/statuses/{sha}","languages_url":"https://api.github.com/repos/viirya/spark-1/languages","stargazers_url":"https://api.github.com/repos/viirya/spark-1/stargazers","contributors_url":"https://api.github.com/repos/viirya/spark-1/contributors","subscribers_url":"https://api.github.com/repos/viirya/spark-1/subscribers","subscription_url":"https://api.github.com/repos/viirya/spark-1/subscription","commits_url":"https://api.github.com/repos/viirya/spark-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/viirya/spark-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/viirya/spark-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/viirya/spark-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/viirya/spark-1/contents/{+path}","compare_url":"https://api.github.com/repos/viirya/spark-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/viirya/spark-1/merges","archive_url":"https://api.github.com/repos/viirya/spark-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/viirya/spark-1/downloads","issues_url":"https://api.github.com/repos/viirya/spark-1/issues{/number}","pulls_url":"https://api.github.com/repos/viirya/spark-1/pulls{/number}","milestones_url":"https://api.github.com/repos/viirya/spark-1/milestones{/number}","notifications_url":"https://api.github.com/repos/viirya/spark-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/viirya/spark-1/labels{/name}","releases_url":"https://api.github.com/repos/viirya/spark-1/releases{/id}","deployments_url":"https://api.github.com/repos/viirya/spark-1/deployments","created_at":"2014-07-03T15:40:08Z","updated_at":"2016-01-18T07:54:15Z","pushed_at":"2016-06-27T09:41:30Z","git_url":"git://github.com/viirya/spark-1.git","ssh_url":"git@github.com:viirya/spark-1.git","clone_url":"https://github.com/viirya/spark-1.git","svn_url":"https://github.com/viirya/spark-1","homepage":null,"size":172875,"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":"6d0f921aedfdd3b7e8472b6776d0c7d8299190bd","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-27T13:11:29Z","pushed_at":"2016-06-27T13:47:49Z","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":499357,"stargazers_count":9081,"watchers_count":9081,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8420,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":406,"forks":8420,"open_issues":406,"watchers":9081,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/13778"},"html":{"href":"https://github.com/apache/spark/pull/13778"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/13778"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/13778/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/13778/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/13778/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/a0b81ba448018200eb8947bc496d8f07d87a64b8"}}}}
{"actor":{"display_login":"viirya"}}