{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/184032077","pull_request_review_id":115143356,"id":184032077,"diff_hunk":"@@ -112,6 +112,14 @@ object TypeCoercion {\n         StructField(f1.name, dataType, nullable = f1.nullable || f2.nullable)\n       }))\n \n+    case (a1 @ ArrayType(et1, hasNull1), a2 @ ArrayType(et2, hasNull2)) if a1.sameType(a2) =>\n+      findTightestCommonType(et1, et2).map(ArrayType(_, hasNull1 || hasNull2))\n+\n+    case (m1 @ MapType(kt1, vt1, hasNull1), m2 @ MapType(kt2, vt2, hasNull2)) if m1.sameType(m2) =>\n+      val keyType = findTightestCommonType(kt1, kt2)\n+      val valueType = findTightestCommonType(vt1, vt2)","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala","position":9,"original_position":9,"commit_id":"4b1ce3684ead1af50cbb76497d0ae07b70d24f43","original_commit_id":"4b1ce3684ead1af50cbb76497d0ae07b70d24f43","user":{"login":"HyukjinKwon","id":6477701,"avatar_url":"https://avatars0.githubusercontent.com/u/6477701?v=4","gravatar_id":"","url":"https://api.github.com/users/HyukjinKwon","html_url":"https://github.com/HyukjinKwon","followers_url":"https://api.github.com/users/HyukjinKwon/followers","following_url":"https://api.github.com/users/HyukjinKwon/following{/other_user}","gists_url":"https://api.github.com/users/HyukjinKwon/gists{/gist_id}","starred_url":"https://api.github.com/users/HyukjinKwon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HyukjinKwon/subscriptions","organizations_url":"https://api.github.com/users/HyukjinKwon/orgs","repos_url":"https://api.github.com/users/HyukjinKwon/repos","events_url":"https://api.github.com/users/HyukjinKwon/events{/privacy}","received_events_url":"https://api.github.com/users/HyukjinKwon/received_events","type":"User","site_admin":false},"body":"Sure, it's orthogonal. Yup, I was just wondering. I am okay to leave this out of this PR.","created_at":"2018-04-25T11:59:02Z","updated_at":"2018-04-25T11:59:02Z","html_url":"https://github.com/apache/spark/pull/21100#discussion_r184032077","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/21100","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/184032077"},"html":{"href":"https://github.com/apache/spark/pull/21100#discussion_r184032077"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/21100"}},"in_reply_to_id":184027821},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/21100","id":182503237,"html_url":"https://github.com/apache/spark/pull/21100","diff_url":"https://github.com/apache/spark/pull/21100.diff","patch_url":"https://github.com/apache/spark/pull/21100.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/21100","number":21100,"state":"closed","locked":false,"title":"[SPARK-24012][SQL] Union of map and other compatible column","user":{"login":"liutang123","id":17537020,"avatar_url":"https://avatars3.githubusercontent.com/u/17537020?v=4","gravatar_id":"","url":"https://api.github.com/users/liutang123","html_url":"https://github.com/liutang123","followers_url":"https://api.github.com/users/liutang123/followers","following_url":"https://api.github.com/users/liutang123/following{/other_user}","gists_url":"https://api.github.com/users/liutang123/gists{/gist_id}","starred_url":"https://api.github.com/users/liutang123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liutang123/subscriptions","organizations_url":"https://api.github.com/users/liutang123/orgs","repos_url":"https://api.github.com/users/liutang123/repos","events_url":"https://api.github.com/users/liutang123/events{/privacy}","received_events_url":"https://api.github.com/users/liutang123/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\nUnion of map and other compatible column result in unresolved operator 'Union; exception\r\n\r\nReproduction\r\n`spark-sql>select map(1,2), 'str' union all select map(1,2,3,null), 1`\r\nOutput:\r\n```\r\nError in query: unresolved operator 'Union;;\r\n'Union\r\n:- Project [map(1, 2) AS map(1, 2)#106, str AS str#107]\r\n:  +- OneRowRelation$\r\n+- Project [map(1, cast(2 as int), 3, cast(null as int)) AS map(1, CAST(2 AS INT), 3, CAST(NULL AS INT))#109, 1 AS 1#108]\r\n   +- OneRowRelation$\r\n```\r\nSo, we should cast part of columns to be compatible when appropriate.\r\n\r\n## How was this patch tested?\r\nAdded a test (query union of map and other columns) to SQLQueryTestSuite's union.sql.","created_at":"2018-04-18T14:43:36Z","updated_at":"2018-04-25T11:59:02Z","closed_at":"2018-04-25T10:14:56Z","merged_at":null,"merge_commit_sha":"dfce1adda2c0a85828edf25081414df4e548faae","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/21100/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/21100/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/21100/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/4b1ce3684ead1af50cbb76497d0ae07b70d24f43","head":{"label":"liutang123:SPARK-24012","ref":"SPARK-24012","sha":"4b1ce3684ead1af50cbb76497d0ae07b70d24f43","user":{"login":"liutang123","id":17537020,"avatar_url":"https://avatars3.githubusercontent.com/u/17537020?v=4","gravatar_id":"","url":"https://api.github.com/users/liutang123","html_url":"https://github.com/liutang123","followers_url":"https://api.github.com/users/liutang123/followers","following_url":"https://api.github.com/users/liutang123/following{/other_user}","gists_url":"https://api.github.com/users/liutang123/gists{/gist_id}","starred_url":"https://api.github.com/users/liutang123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liutang123/subscriptions","organizations_url":"https://api.github.com/users/liutang123/orgs","repos_url":"https://api.github.com/users/liutang123/repos","events_url":"https://api.github.com/users/liutang123/events{/privacy}","received_events_url":"https://api.github.com/users/liutang123/received_events","type":"User","site_admin":false},"repo":{"id":84201209,"name":"spark","full_name":"liutang123/spark","owner":{"login":"liutang123","id":17537020,"avatar_url":"https://avatars3.githubusercontent.com/u/17537020?v=4","gravatar_id":"","url":"https://api.github.com/users/liutang123","html_url":"https://github.com/liutang123","followers_url":"https://api.github.com/users/liutang123/followers","following_url":"https://api.github.com/users/liutang123/following{/other_user}","gists_url":"https://api.github.com/users/liutang123/gists{/gist_id}","starred_url":"https://api.github.com/users/liutang123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liutang123/subscriptions","organizations_url":"https://api.github.com/users/liutang123/orgs","repos_url":"https://api.github.com/users/liutang123/repos","events_url":"https://api.github.com/users/liutang123/events{/privacy}","received_events_url":"https://api.github.com/users/liutang123/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liutang123/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/liutang123/spark","forks_url":"https://api.github.com/repos/liutang123/spark/forks","keys_url":"https://api.github.com/repos/liutang123/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liutang123/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liutang123/spark/teams","hooks_url":"https://api.github.com/repos/liutang123/spark/hooks","issue_events_url":"https://api.github.com/repos/liutang123/spark/issues/events{/number}","events_url":"https://api.github.com/repos/liutang123/spark/events","assignees_url":"https://api.github.com/repos/liutang123/spark/assignees{/user}","branches_url":"https://api.github.com/repos/liutang123/spark/branches{/branch}","tags_url":"https://api.github.com/repos/liutang123/spark/tags","blobs_url":"https://api.github.com/repos/liutang123/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liutang123/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liutang123/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/liutang123/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liutang123/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/liutang123/spark/languages","stargazers_url":"https://api.github.com/repos/liutang123/spark/stargazers","contributors_url":"https://api.github.com/repos/liutang123/spark/contributors","subscribers_url":"https://api.github.com/repos/liutang123/spark/subscribers","subscription_url":"https://api.github.com/repos/liutang123/spark/subscription","commits_url":"https://api.github.com/repos/liutang123/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/liutang123/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/liutang123/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/liutang123/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/liutang123/spark/contents/{+path}","compare_url":"https://api.github.com/repos/liutang123/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liutang123/spark/merges","archive_url":"https://api.github.com/repos/liutang123/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liutang123/spark/downloads","issues_url":"https://api.github.com/repos/liutang123/spark/issues{/number}","pulls_url":"https://api.github.com/repos/liutang123/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/liutang123/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/liutang123/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liutang123/spark/labels{/name}","releases_url":"https://api.github.com/repos/liutang123/spark/releases{/id}","deployments_url":"https://api.github.com/repos/liutang123/spark/deployments","created_at":"2017-03-07T13:18:08Z","updated_at":"2017-06-21T04:21:40Z","pushed_at":"2018-04-24T08:31:53Z","git_url":"git://github.com/liutang123/spark.git","ssh_url":"git@github.com:liutang123/spark.git","clone_url":"https://github.com/liutang123/spark.git","svn_url":"https://github.com/liutang123/spark","homepage":null,"size":264464,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"f81fa478ff990146e2a8e463ac252271448d96f5","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","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://avatars0.githubusercontent.com/u/47359?v=4","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":"2018-04-25T11:45:01Z","pushed_at":"2018-04-25T11:06:38Z","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":268723,"stargazers_count":17062,"watchers_count":17062,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15627,"mirror_url":null,"archived":false,"open_issues_count":515,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":15627,"open_issues":515,"watchers":17062,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/21100"},"html":{"href":"https://github.com/apache/spark/pull/21100"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/21100"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/21100/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/21100/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/21100/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/4b1ce3684ead1af50cbb76497d0ae07b70d24f43"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"HyukjinKwon"}}