{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/70938951","id":70938951,"diff_hunk":"@@ -1774,6 +1775,35 @@ class Analyzer(\n   }\n \n   /**\n+   * Substitute Hints.\n+   * - BROADCAST/BROADCASTJOIN/MAPJOIN match the closest table with the given name parameters.","path":"sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala","position":15,"original_position":15,"commit_id":"f77a0fafbce0195133a9680c2b636222ba491e2b","original_commit_id":"f77a0fafbce0195133a9680c2b636222ba491e2b","user":{"login":"dongjoon-hyun","id":9700541,"avatar_url":"https://avatars.githubusercontent.com/u/9700541?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjoon-hyun","html_url":"https://github.com/dongjoon-hyun","followers_url":"https://api.github.com/users/dongjoon-hyun/followers","following_url":"https://api.github.com/users/dongjoon-hyun/following{/other_user}","gists_url":"https://api.github.com/users/dongjoon-hyun/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjoon-hyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjoon-hyun/subscriptions","organizations_url":"https://api.github.com/users/dongjoon-hyun/orgs","repos_url":"https://api.github.com/users/dongjoon-hyun/repos","events_url":"https://api.github.com/users/dongjoon-hyun/events{/privacy}","received_events_url":"https://api.github.com/users/dongjoon-hyun/received_events","type":"User","site_admin":false},"body":"For this one, we have this rule in `Batch(\"Substitution\")`. I think that's fairly enough information.","created_at":"2016-07-15T08:37:08Z","updated_at":"2016-07-15T08:37:08Z","html_url":"https://github.com/apache/spark/pull/14132#discussion_r70938951","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/14132","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/70938951"},"html":{"href":"https://github.com/apache/spark/pull/14132#discussion_r70938951"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/14132"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/14132","id":76916694,"html_url":"https://github.com/apache/spark/pull/14132","diff_url":"https://github.com/apache/spark/pull/14132.diff","patch_url":"https://github.com/apache/spark/pull/14132.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/14132","number":14132,"state":"open","locked":false,"title":"[SPARK-16475][SQL] Broadcast Hint for SQL Queries","user":{"login":"dongjoon-hyun","id":9700541,"avatar_url":"https://avatars.githubusercontent.com/u/9700541?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjoon-hyun","html_url":"https://github.com/dongjoon-hyun","followers_url":"https://api.github.com/users/dongjoon-hyun/followers","following_url":"https://api.github.com/users/dongjoon-hyun/following{/other_user}","gists_url":"https://api.github.com/users/dongjoon-hyun/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjoon-hyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjoon-hyun/subscriptions","organizations_url":"https://api.github.com/users/dongjoon-hyun/orgs","repos_url":"https://api.github.com/users/dongjoon-hyun/repos","events_url":"https://api.github.com/users/dongjoon-hyun/events{/privacy}","received_events_url":"https://api.github.com/users/dongjoon-hyun/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\nThis PR aims to achieve the following two goals in Spark SQL.\r\n\r\n**1. Generic Hint Syntax**\r\nThe generic hints are parsed and handled by **Analyzer** or **Optimizers**. The unknown hints are ignored with DEBUG level message as a default operation.\r\n```sql\r\nSELECT /*+ MAPJOIN(t) */ * FROM t\r\nSELECT /*+ STREAMTABLE(a,b,c) */ * FROM t\r\nSELECT /*+ INDEX(t emp_job_ix) */ * FROM t\r\n```\r\n\r\n**2. Broadcast Hints**\r\nThe followings are recognized.\r\n```sql\r\nSELECT /*+ MAPJOIN(t) */ * FROM t JOIN u ON t.id = u.id\r\nSELECT /*+ BROADCAST(u) */ * FROM t JOIN u ON t.id = u.id\r\nSELECT /*+ BROADCASTJOIN(u) */ * FROM t JOIN u ON t.id = u.id\r\n```\r\n\r\n**Examples**\r\n```scala\r\nscala> spark.range(1000000000).createOrReplaceTempView(\"t\")\r\nscala> spark.range(1000000000).createOrReplaceTempView(\"u\")\r\n\r\nscala> sql(\"SELECT * FROM t JOIN u ON t.id = u.id\").explain\r\n== Physical Plan ==\r\n*SortMergeJoin [id#0L], [id#4L], Inner\r\n:- *Sort [id#0L ASC], false, 0\r\n:  +- Exchange hashpartitioning(id#0L, 200)\r\n:     +- *Range (0, 1000000000, splits=8)\r\n+- *Sort [id#4L ASC], false, 0\r\n   +- ReusedExchange [id#4L], Exchange hashpartitioning(id#0L, 200)\r\n\r\nscala> sql(\"SELECT /*+ MAPJOIN(t) */ * FROM t JOIN u ON t.id = u.id\").explain\r\n== Physical Plan ==\r\n*BroadcastHashJoin [id#0L], [id#4L], Inner, BuildLeft\r\n:- BroadcastExchange HashedRelationBroadcastMode(List(input[0, bigint, false]))\r\n:  +- *Range (0, 1000000000, splits=8)\r\n+- *Range (0, 1000000000, splits=8)\r\n\r\nscala> sql(\"SELECT /*+ MAPJOIN(u) */ * FROM t JOIN u ON t.id = u.id\").explain\r\n== Physical Plan ==\r\n*BroadcastHashJoin [id#0L], [id#4L], Inner, BuildRight\r\n:- *Range (0, 1000000000, splits=8)\r\n+- BroadcastExchange HashedRelationBroadcastMode(List(input[0, bigint, false]))\r\n   +- *Range (0, 1000000000, splits=8)\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nPass the Jenkins tests with new testcases.","created_at":"2016-07-11T08:34:55Z","updated_at":"2016-07-15T08:37:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90ad394a54f0e98afc61990d87262935d2bf4bcf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/14132/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/14132/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/14132/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/f77a0fafbce0195133a9680c2b636222ba491e2b","head":{"label":"dongjoon-hyun:SPARK-16475","ref":"SPARK-16475","sha":"f77a0fafbce0195133a9680c2b636222ba491e2b","user":{"login":"dongjoon-hyun","id":9700541,"avatar_url":"https://avatars.githubusercontent.com/u/9700541?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjoon-hyun","html_url":"https://github.com/dongjoon-hyun","followers_url":"https://api.github.com/users/dongjoon-hyun/followers","following_url":"https://api.github.com/users/dongjoon-hyun/following{/other_user}","gists_url":"https://api.github.com/users/dongjoon-hyun/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjoon-hyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjoon-hyun/subscriptions","organizations_url":"https://api.github.com/users/dongjoon-hyun/orgs","repos_url":"https://api.github.com/users/dongjoon-hyun/repos","events_url":"https://api.github.com/users/dongjoon-hyun/events{/privacy}","received_events_url":"https://api.github.com/users/dongjoon-hyun/received_events","type":"User","site_admin":false},"repo":{"id":28900400,"name":"spark","full_name":"dongjoon-hyun/spark","owner":{"login":"dongjoon-hyun","id":9700541,"avatar_url":"https://avatars.githubusercontent.com/u/9700541?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjoon-hyun","html_url":"https://github.com/dongjoon-hyun","followers_url":"https://api.github.com/users/dongjoon-hyun/followers","following_url":"https://api.github.com/users/dongjoon-hyun/following{/other_user}","gists_url":"https://api.github.com/users/dongjoon-hyun/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjoon-hyun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjoon-hyun/subscriptions","organizations_url":"https://api.github.com/users/dongjoon-hyun/orgs","repos_url":"https://api.github.com/users/dongjoon-hyun/repos","events_url":"https://api.github.com/users/dongjoon-hyun/events{/privacy}","received_events_url":"https://api.github.com/users/dongjoon-hyun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dongjoon-hyun/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/dongjoon-hyun/spark","forks_url":"https://api.github.com/repos/dongjoon-hyun/spark/forks","keys_url":"https://api.github.com/repos/dongjoon-hyun/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dongjoon-hyun/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dongjoon-hyun/spark/teams","hooks_url":"https://api.github.com/repos/dongjoon-hyun/spark/hooks","issue_events_url":"https://api.github.com/repos/dongjoon-hyun/spark/issues/events{/number}","events_url":"https://api.github.com/repos/dongjoon-hyun/spark/events","assignees_url":"https://api.github.com/repos/dongjoon-hyun/spark/assignees{/user}","branches_url":"https://api.github.com/repos/dongjoon-hyun/spark/branches{/branch}","tags_url":"https://api.github.com/repos/dongjoon-hyun/spark/tags","blobs_url":"https://api.github.com/repos/dongjoon-hyun/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dongjoon-hyun/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dongjoon-hyun/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/dongjoon-hyun/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dongjoon-hyun/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/dongjoon-hyun/spark/languages","stargazers_url":"https://api.github.com/repos/dongjoon-hyun/spark/stargazers","contributors_url":"https://api.github.com/repos/dongjoon-hyun/spark/contributors","subscribers_url":"https://api.github.com/repos/dongjoon-hyun/spark/subscribers","subscription_url":"https://api.github.com/repos/dongjoon-hyun/spark/subscription","commits_url":"https://api.github.com/repos/dongjoon-hyun/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/dongjoon-hyun/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/dongjoon-hyun/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/dongjoon-hyun/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/dongjoon-hyun/spark/contents/{+path}","compare_url":"https://api.github.com/repos/dongjoon-hyun/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dongjoon-hyun/spark/merges","archive_url":"https://api.github.com/repos/dongjoon-hyun/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dongjoon-hyun/spark/downloads","issues_url":"https://api.github.com/repos/dongjoon-hyun/spark/issues{/number}","pulls_url":"https://api.github.com/repos/dongjoon-hyun/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/dongjoon-hyun/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/dongjoon-hyun/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dongjoon-hyun/spark/labels{/name}","releases_url":"https://api.github.com/repos/dongjoon-hyun/spark/releases{/id}","deployments_url":"https://api.github.com/repos/dongjoon-hyun/spark/deployments","created_at":"2015-01-07T05:46:34Z","updated_at":"2016-02-21T23:51:21Z","pushed_at":"2016-07-15T06:00:13Z","git_url":"git://github.com/dongjoon-hyun/spark.git","ssh_url":"git@github.com:dongjoon-hyun/spark.git","clone_url":"https://github.com/dongjoon-hyun/spark.git","svn_url":"https://github.com/dongjoon-hyun/spark","homepage":null,"size":166860,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"7f968867ff61c6b1a007874ee7e3a7421d94d373","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-07-15T08:35:04Z","pushed_at":"2016-07-15T08:35:50Z","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":500488,"stargazers_count":9308,"watchers_count":9308,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8635,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":432,"forks":8635,"open_issues":432,"watchers":9308,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/14132"},"html":{"href":"https://github.com/apache/spark/pull/14132"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/14132"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/14132/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/14132/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/14132/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/f77a0fafbce0195133a9680c2b636222ba491e2b"}}}}
{"actor":{"display_login":"dongjoon-hyun"}}