{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/245351322","pull_request_review_id":189438478,"id":245351322,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NTM1MTMyMg==","diff_hunk":"@@ -59,3 +76,41 @@ case class HintInfo(broadcast: Boolean = false) {\n     if (hints.isEmpty) \"none\" else hints.mkString(\"(\", \", \", \")\")\n   }\n }\n+\n+/**\n+ * Replaces [[ResolvedHint]] operators from the plan. Move the [[HintInfo]] to associated [[Join]]\n+ * operators, otherwise remove it if no [[Join]] operator is matched.\n+ */\n+object EliminateResolvedHint extends Rule[LogicalPlan] {\n+  // This is also called in the beginning of the optimization phase, and as a result\n+  // is using transformUp rather than resolveOperators.\n+  def apply(plan: LogicalPlan): LogicalPlan = {\n+    val pulledUp = plan transformUp {\n+      case j: Join =>\n+        val leftHint = mergeHints(collectHints(j.left))\n+        val rightHint = mergeHints(collectHints(j.right))\n+        j.copy(hint = JoinHint(leftHint, rightHint))\n+    }\n+    pulledUp.transform {\n+      case h: ResolvedHint => h.child\n+    }\n+  }\n+\n+  def mergeHints(hints: Seq[HintInfo]): Option[HintInfo] = {\n+    hints.reduceOption((h1, h2) => HintInfo(\n+      broadcast = h1.broadcast || h2.broadcast))\n+  }\n+\n+  def collectHints(plan: LogicalPlan): Seq[HintInfo] = {\n+    plan match {\n+      case h: ResolvedHint => collectHints(h.child) :+ h.hints\n+      case u: UnaryNode => collectHints(u.child)","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/hints.scala","position":71,"original_position":71,"commit_id":"470d682b11971a927ace25ba448e289bccca36a2","original_commit_id":"470d682b11971a927ace25ba448e289bccca36a2","user":{"login":"maryannxue","id":4171904,"node_id":"MDQ6VXNlcjQxNzE5MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4171904?v=4","gravatar_id":"","url":"https://api.github.com/users/maryannxue","html_url":"https://github.com/maryannxue","followers_url":"https://api.github.com/users/maryannxue/followers","following_url":"https://api.github.com/users/maryannxue/following{/other_user}","gists_url":"https://api.github.com/users/maryannxue/gists{/gist_id}","starred_url":"https://api.github.com/users/maryannxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maryannxue/subscriptions","organizations_url":"https://api.github.com/users/maryannxue/orgs","repos_url":"https://api.github.com/users/maryannxue/repos","events_url":"https://api.github.com/users/maryannxue/events{/privacy}","received_events_url":"https://api.github.com/users/maryannxue/received_events","type":"User","site_admin":false},"body":"This is following the original behavior although I'm more inclined to make it work as you suggested here.","created_at":"2019-01-04T16:39:15Z","updated_at":"2019-01-04T16:39:15Z","html_url":"https://github.com/apache/spark/pull/23036#discussion_r245351322","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/23036","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/245351322"},"html":{"href":"https://github.com/apache/spark/pull/23036#discussion_r245351322"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/23036"}},"in_reply_to_id":245298669},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/23036","id":230947852,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwOTQ3ODUy","html_url":"https://github.com/apache/spark/pull/23036","diff_url":"https://github.com/apache/spark/pull/23036.diff","patch_url":"https://github.com/apache/spark/pull/23036.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/23036","number":23036,"state":"open","locked":false,"title":"[SPARK-26065][SQL] Change query hint from a `LogicalPlan` to a field","user":{"login":"maryannxue","id":4171904,"node_id":"MDQ6VXNlcjQxNzE5MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4171904?v=4","gravatar_id":"","url":"https://api.github.com/users/maryannxue","html_url":"https://github.com/maryannxue","followers_url":"https://api.github.com/users/maryannxue/followers","following_url":"https://api.github.com/users/maryannxue/following{/other_user}","gists_url":"https://api.github.com/users/maryannxue/gists{/gist_id}","starred_url":"https://api.github.com/users/maryannxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maryannxue/subscriptions","organizations_url":"https://api.github.com/users/maryannxue/orgs","repos_url":"https://api.github.com/users/maryannxue/repos","events_url":"https://api.github.com/users/maryannxue/events{/privacy}","received_events_url":"https://api.github.com/users/maryannxue/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nThe existing query hint implementation relies on a logical plan node `ResolvedHint` to store query hints in logical plans, and on `Statistics` in physical plans. Since `ResolvedHint` is not really a logical operator and can break the pattern matching for existing and future optimization rules, it is a issue to the Optimizer as the old `AnalysisBarrier` was to the Analyzer.\r\n\r\nGiven the fact that all our query hints are either 1) a join hint, i.e., broadcast hint; or 2) a re-partition hint, which is indeed an operator, we only need to add a hint field on the Join plan and that will be a good enough solution for the current hint usage.\r\n\r\nThis PR is to let `Join` node have a hint for its left sub-tree and another hint for its right sub-tree and each hint is a merged result of all the effective hints specified in the corresponding sub-tree. The \"effectiveness\" of a hint, i.e., whether that hint should be propagated to the `Join` node, is currently consistent with the hint propagation rules originally implemented in the `Statistics` approach. Note that the `ResolvedHint` node still has to live through the analysis stage because of the `Dataset` interface, but it will be got rid of and moved to the `Join` node in the \"pre-optimization\" stage.\r\n\r\n## How was this patch tested?\r\n\r\nAdded a `JoinHintSuite`.","created_at":"2018-11-14T19:07:33Z","updated_at":"2019-01-04T16:39:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"791c6f869909fd3b270dcb9f8963459c608b11f8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/23036/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/23036/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/23036/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/470d682b11971a927ace25ba448e289bccca36a2","head":{"label":"maryannxue:query-hint","ref":"query-hint","sha":"470d682b11971a927ace25ba448e289bccca36a2","user":{"login":"maryannxue","id":4171904,"node_id":"MDQ6VXNlcjQxNzE5MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4171904?v=4","gravatar_id":"","url":"https://api.github.com/users/maryannxue","html_url":"https://github.com/maryannxue","followers_url":"https://api.github.com/users/maryannxue/followers","following_url":"https://api.github.com/users/maryannxue/following{/other_user}","gists_url":"https://api.github.com/users/maryannxue/gists{/gist_id}","starred_url":"https://api.github.com/users/maryannxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maryannxue/subscriptions","organizations_url":"https://api.github.com/users/maryannxue/orgs","repos_url":"https://api.github.com/users/maryannxue/repos","events_url":"https://api.github.com/users/maryannxue/events{/privacy}","received_events_url":"https://api.github.com/users/maryannxue/received_events","type":"User","site_admin":false},"repo":{"id":104110775,"node_id":"MDEwOlJlcG9zaXRvcnkxMDQxMTA3NzU=","name":"spark","full_name":"maryannxue/spark","private":false,"owner":{"login":"maryannxue","id":4171904,"node_id":"MDQ6VXNlcjQxNzE5MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4171904?v=4","gravatar_id":"","url":"https://api.github.com/users/maryannxue","html_url":"https://github.com/maryannxue","followers_url":"https://api.github.com/users/maryannxue/followers","following_url":"https://api.github.com/users/maryannxue/following{/other_user}","gists_url":"https://api.github.com/users/maryannxue/gists{/gist_id}","starred_url":"https://api.github.com/users/maryannxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maryannxue/subscriptions","organizations_url":"https://api.github.com/users/maryannxue/orgs","repos_url":"https://api.github.com/users/maryannxue/repos","events_url":"https://api.github.com/users/maryannxue/events{/privacy}","received_events_url":"https://api.github.com/users/maryannxue/received_events","type":"User","site_admin":false},"html_url":"https://github.com/maryannxue/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/maryannxue/spark","forks_url":"https://api.github.com/repos/maryannxue/spark/forks","keys_url":"https://api.github.com/repos/maryannxue/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maryannxue/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maryannxue/spark/teams","hooks_url":"https://api.github.com/repos/maryannxue/spark/hooks","issue_events_url":"https://api.github.com/repos/maryannxue/spark/issues/events{/number}","events_url":"https://api.github.com/repos/maryannxue/spark/events","assignees_url":"https://api.github.com/repos/maryannxue/spark/assignees{/user}","branches_url":"https://api.github.com/repos/maryannxue/spark/branches{/branch}","tags_url":"https://api.github.com/repos/maryannxue/spark/tags","blobs_url":"https://api.github.com/repos/maryannxue/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maryannxue/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maryannxue/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/maryannxue/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maryannxue/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/maryannxue/spark/languages","stargazers_url":"https://api.github.com/repos/maryannxue/spark/stargazers","contributors_url":"https://api.github.com/repos/maryannxue/spark/contributors","subscribers_url":"https://api.github.com/repos/maryannxue/spark/subscribers","subscription_url":"https://api.github.com/repos/maryannxue/spark/subscription","commits_url":"https://api.github.com/repos/maryannxue/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/maryannxue/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/maryannxue/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/maryannxue/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/maryannxue/spark/contents/{+path}","compare_url":"https://api.github.com/repos/maryannxue/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maryannxue/spark/merges","archive_url":"https://api.github.com/repos/maryannxue/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maryannxue/spark/downloads","issues_url":"https://api.github.com/repos/maryannxue/spark/issues{/number}","pulls_url":"https://api.github.com/repos/maryannxue/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/maryannxue/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/maryannxue/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maryannxue/spark/labels{/name}","releases_url":"https://api.github.com/repos/maryannxue/spark/releases{/id}","deployments_url":"https://api.github.com/repos/maryannxue/spark/deployments","created_at":"2017-09-19T18:13:47Z","updated_at":"2019-01-02T18:05:00Z","pushed_at":"2019-01-02T20:21:35Z","git_url":"git://github.com/maryannxue/spark.git","ssh_url":"git@github.com:maryannxue/spark.git","clone_url":"https://github.com/maryannxue/spark.git","svn_url":"https://github.com/maryannxue/spark","homepage":null,"size":286037,"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","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"4bdfda92a1c570d7a1142ee30eb41e37661bc240","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","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,"node_id":"MDEwOlJlcG9zaXRvcnkxNzE2NTY1OA==","name":"spark","full_name":"apache/spark","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","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},"html_url":"https://github.com/apache/spark","description":"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":"2019-01-04T14:51:51Z","pushed_at":"2019-01-04T16:36:15Z","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":"","size":290071,"stargazers_count":20108,"watchers_count":20108,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17832,"mirror_url":null,"archived":false,"open_issues_count":465,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17832,"open_issues":465,"watchers":20108,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/23036"},"html":{"href":"https://github.com/apache/spark/pull/23036"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/23036"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/23036/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/23036/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/23036/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/470d682b11971a927ace25ba448e289bccca36a2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"maryannxue"}}