{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/175971428","pull_request_review_id":105592225,"id":175971428,"diff_hunk":"@@ -145,4 +159,15 @@ class JoinOptimizationSuite extends PlanTest {\n     }\n     assert(broadcastChildren.size == 1)\n   }\n+\n+  test(\"SPARK-23172 skip projections when flattening joins\") {","path":"sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/JoinOptimizationSuite.scala","position":74,"original_position":74,"commit_id":"f1a65583340daefed6c144fd9c78858690ac92cb","original_commit_id":"f1a65583340daefed6c144fd9c78858690ac92cb","user":{"login":"maropu","id":692303,"avatar_url":"https://avatars3.githubusercontent.com/u/692303?v=4","gravatar_id":"","url":"https://api.github.com/users/maropu","html_url":"https://github.com/maropu","followers_url":"https://api.github.com/users/maropu/followers","following_url":"https://api.github.com/users/maropu/following{/other_user}","gists_url":"https://api.github.com/users/maropu/gists{/gist_id}","starred_url":"https://api.github.com/users/maropu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maropu/subscriptions","organizations_url":"https://api.github.com/users/maropu/orgs","repos_url":"https://api.github.com/users/maropu/repos","events_url":"https://api.github.com/users/maropu/events{/privacy}","received_events_url":"https://api.github.com/users/maropu/received_events","type":"User","site_admin":false},"body":"ok","created_at":"2018-03-21T02:00:57Z","updated_at":"2018-03-21T02:00:57Z","html_url":"https://github.com/apache/spark/pull/20345#discussion_r175971428","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/20345","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/175971428"},"html":{"href":"https://github.com/apache/spark/pull/20345#discussion_r175971428"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/20345"}},"in_reply_to_id":175727668},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/20345","id":164188883,"html_url":"https://github.com/apache/spark/pull/20345","diff_url":"https://github.com/apache/spark/pull/20345.diff","patch_url":"https://github.com/apache/spark/pull/20345.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/20345","number":20345,"state":"open","locked":false,"title":"[SPARK-23172][SQL] Expand the ReorderJoin rule to handle Project nodes","user":{"login":"maropu","id":692303,"avatar_url":"https://avatars3.githubusercontent.com/u/692303?v=4","gravatar_id":"","url":"https://api.github.com/users/maropu","html_url":"https://github.com/maropu","followers_url":"https://api.github.com/users/maropu/followers","following_url":"https://api.github.com/users/maropu/following{/other_user}","gists_url":"https://api.github.com/users/maropu/gists{/gist_id}","starred_url":"https://api.github.com/users/maropu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maropu/subscriptions","organizations_url":"https://api.github.com/users/maropu/orgs","repos_url":"https://api.github.com/users/maropu/repos","events_url":"https://api.github.com/users/maropu/events{/privacy}","received_events_url":"https://api.github.com/users/maropu/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\nThe current `ReorderJoin` optimizer rule cannot flatten a pattern `Join -> Project -> Join` because `ExtractFiltersAndInnerJoins` doesn't handle `Project` nodes. So, the current master cannot reorder joins in a query below;\r\n```\r\nval df1 = spark.range(100).selectExpr(\"id % 10 AS k0\", s\"id % 10 AS k1\", s\"id % 10 AS k2\", \"id AS v1\")\r\nval df2 = spark.range(10).selectExpr(\"id AS k0\", \"id AS v2\")\r\nval df3 = spark.range(10).selectExpr(\"id AS k1\", \"id AS v3\")\r\nval df4 = spark.range(10).selectExpr(\"id AS k2\", \"id AS v4\")\r\ndf1.join(df2, \"k0\").join(df3, \"k1\").join(df4, \"k2\").explain(true)\r\n\r\n== Analyzed Logical Plan ==\r\nk2: bigint, k1: bigint, k0: bigint, v1: bigint, v2: bigint, v3: bigint, v4: bigint\r\nProject [k2#5L, k1#4L, k0#3L, v1#6L, v2#16L, v3#24L, v4#32L]\r\n+- Join Inner, (k2#5L = k2#31L)\r\n   :- Project [k1#4L, k0#3L, k2#5L, v1#6L, v2#16L, v3#24L]\r\n   :  +- Join Inner, (k1#4L = k1#23L)\r\n   :     :- Project [k0#3L, k1#4L, k2#5L, v1#6L, v2#16L]\r\n   :     :  +- Join Inner, (k0#3L = k0#15L)\r\n   :     :     :- Project [(id#0L % cast(10 as bigint)) AS k0#3L, (id#0L % cast(10 as bigint)) AS k1#4L, (id#0L % cast(10 as bigint)) AS k2#5L, id#0\r\nL AS v1#6L]\r\n   :     :     :  +- Range (0, 100, step=1, splits=Some(4))\r\n   :     :     +- Project [id#12L AS k0#15L, id#12L AS v2#16L]\r\n   :     :        +- Range (0, 10, step=1, splits=Some(4))\r\n   :     +- Project [id#20L AS k1#23L, id#20L AS v3#24L]\r\n   :        +- Range (0, 10, step=1, splits=Some(4))\r\n   +- Project [id#28L AS k2#31L, id#28L AS v4#32L]\r\n      +- Range (0, 10, step=1, splits=Some(4))\r\n```\r\nTo reorder the query, this pr added code to handle `Project` in `ExtractFiltersAndInnerJoins`.\r\n\r\n## How was this patch tested?\r\nAdded new tests in `JoinOptimizationSuite` and modified some existing tests\r\nin `JoinReorderSuite` and `StarJoinReorderSuite`.\r\n","created_at":"2018-01-21T18:52:21Z","updated_at":"2018-03-21T02:00:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d95e0a8948fda5b70c372e1104707daebd5cf6d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/20345/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/20345/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/20345/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/f1a65583340daefed6c144fd9c78858690ac92cb","head":{"label":"maropu:FixFlattenJoins","ref":"FixFlattenJoins","sha":"f1a65583340daefed6c144fd9c78858690ac92cb","user":{"login":"maropu","id":692303,"avatar_url":"https://avatars3.githubusercontent.com/u/692303?v=4","gravatar_id":"","url":"https://api.github.com/users/maropu","html_url":"https://github.com/maropu","followers_url":"https://api.github.com/users/maropu/followers","following_url":"https://api.github.com/users/maropu/following{/other_user}","gists_url":"https://api.github.com/users/maropu/gists{/gist_id}","starred_url":"https://api.github.com/users/maropu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maropu/subscriptions","organizations_url":"https://api.github.com/users/maropu/orgs","repos_url":"https://api.github.com/users/maropu/repos","events_url":"https://api.github.com/users/maropu/events{/privacy}","received_events_url":"https://api.github.com/users/maropu/received_events","type":"User","site_admin":false},"repo":{"id":27115199,"name":"spark","full_name":"maropu/spark","owner":{"login":"maropu","id":692303,"avatar_url":"https://avatars3.githubusercontent.com/u/692303?v=4","gravatar_id":"","url":"https://api.github.com/users/maropu","html_url":"https://github.com/maropu","followers_url":"https://api.github.com/users/maropu/followers","following_url":"https://api.github.com/users/maropu/following{/other_user}","gists_url":"https://api.github.com/users/maropu/gists{/gist_id}","starred_url":"https://api.github.com/users/maropu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maropu/subscriptions","organizations_url":"https://api.github.com/users/maropu/orgs","repos_url":"https://api.github.com/users/maropu/repos","events_url":"https://api.github.com/users/maropu/events{/privacy}","received_events_url":"https://api.github.com/users/maropu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maropu/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/maropu/spark","forks_url":"https://api.github.com/repos/maropu/spark/forks","keys_url":"https://api.github.com/repos/maropu/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maropu/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maropu/spark/teams","hooks_url":"https://api.github.com/repos/maropu/spark/hooks","issue_events_url":"https://api.github.com/repos/maropu/spark/issues/events{/number}","events_url":"https://api.github.com/repos/maropu/spark/events","assignees_url":"https://api.github.com/repos/maropu/spark/assignees{/user}","branches_url":"https://api.github.com/repos/maropu/spark/branches{/branch}","tags_url":"https://api.github.com/repos/maropu/spark/tags","blobs_url":"https://api.github.com/repos/maropu/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maropu/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maropu/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/maropu/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maropu/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/maropu/spark/languages","stargazers_url":"https://api.github.com/repos/maropu/spark/stargazers","contributors_url":"https://api.github.com/repos/maropu/spark/contributors","subscribers_url":"https://api.github.com/repos/maropu/spark/subscribers","subscription_url":"https://api.github.com/repos/maropu/spark/subscription","commits_url":"https://api.github.com/repos/maropu/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/maropu/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/maropu/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/maropu/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/maropu/spark/contents/{+path}","compare_url":"https://api.github.com/repos/maropu/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maropu/spark/merges","archive_url":"https://api.github.com/repos/maropu/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maropu/spark/downloads","issues_url":"https://api.github.com/repos/maropu/spark/issues{/number}","pulls_url":"https://api.github.com/repos/maropu/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/maropu/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/maropu/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maropu/spark/labels{/name}","releases_url":"https://api.github.com/repos/maropu/spark/releases{/id}","deployments_url":"https://api.github.com/repos/maropu/spark/deployments","created_at":"2014-11-25T08:00:37Z","updated_at":"2016-01-12T09:36:15Z","pushed_at":"2018-03-21T00:47:29Z","git_url":"git://github.com/maropu/spark.git","ssh_url":"git@github.com:maropu/spark.git","clone_url":"https://github.com/maropu/spark.git","svn_url":"https://github.com/maropu/spark","homepage":null,"size":251443,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"4f43d27c9e97be8605b120b3d7c11c7c61e3ca6f","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-03-21T00:45:53Z","pushed_at":"2018-03-21T01:55:06Z","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":269659,"stargazers_count":16576,"watchers_count":16576,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15243,"mirror_url":null,"archived":false,"open_issues_count":478,"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":15243,"open_issues":478,"watchers":16576,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/20345"},"html":{"href":"https://github.com/apache/spark/pull/20345"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/20345"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/20345/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/20345/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/20345/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/f1a65583340daefed6c144fd9c78858690ac92cb"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"maropu"}}