{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/228053855","pull_request_review_id":168226248,"id":228053855,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODA1Mzg1NQ==","diff_hunk":"@@ -0,0 +1,137 @@\n+// Copyright 2018 PingCAP, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package cascades\n+\n+import (\n+\t\"container/list\"\n+)\n+\n+// ExprIter enumerates all the equivalent expressions in the group according to\n+// the expression pattern.\n+type ExprIter struct {\n+\t// group and element solely identify a group expression.\n+\tgroup   *Group\n+\telement *list.Element\n+\n+\t// matched indicates whether the current group expression binded by the\n+\t// iterator matches the pattern after the creation or iteration.\n+\tmatched bool\n+\n+\t// operand is the node of the pattern tree. The operand type of the group\n+\t// expression must be matched with it.\n+\toperand Operand\n+\n+\t// children is used to iterate the child expressions.\n+\tchildren []*ExprIter\n+}\n+\n+// Next returns the next group expression matches the pattern.\n+func (iter *ExprIter) Next() (found bool) {\n+\tdefer func() {\n+\t\titer.matched = found\n+\t}()\n+\n+\t// Iterate child firstly.\n+\tfor i := len(iter.children) - 1; i >= 0; i-- {\n+\t\titer.children[i].Next()\n+\t\tif !iter.children[i].Matched() {","path":"planner/cascades/expr_iterator.go","position":48,"original_position":48,"commit_id":"099d16e3cfeb318173fdbeb2dfbd424083f24c93","original_commit_id":"099d16e3cfeb318173fdbeb2dfbd424083f24c93","user":{"login":"zz-jason","id":5268763,"node_id":"MDQ6VXNlcjUyNjg3NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/5268763?v=4","gravatar_id":"","url":"https://api.github.com/users/zz-jason","html_url":"https://github.com/zz-jason","followers_url":"https://api.github.com/users/zz-jason/followers","following_url":"https://api.github.com/users/zz-jason/following{/other_user}","gists_url":"https://api.github.com/users/zz-jason/gists{/gist_id}","starred_url":"https://api.github.com/users/zz-jason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz-jason/subscriptions","organizations_url":"https://api.github.com/users/zz-jason/orgs","repos_url":"https://api.github.com/users/zz-jason/repos","events_url":"https://api.github.com/users/zz-jason/events{/privacy}","received_events_url":"https://api.github.com/users/zz-jason/received_events","type":"User","site_admin":false},"body":"okay","created_at":"2018-10-25T07:00:59Z","updated_at":"2018-10-25T07:01:57Z","html_url":"https://github.com/pingcap/tidb/pull/7869#discussion_r228053855","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/7869","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/228053855"},"html":{"href":"https://github.com/pingcap/tidb/pull/7869#discussion_r228053855"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7869"}},"in_reply_to_id":228020196},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/7869","id":221995054,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxOTk1MDU0","html_url":"https://github.com/pingcap/tidb/pull/7869","diff_url":"https://github.com/pingcap/tidb/pull/7869.diff","patch_url":"https://github.com/pingcap/tidb/pull/7869.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/7869","number":7869,"state":"open","locked":false,"title":"planner: support the transformation framework of the cascades planner","user":{"login":"zz-jason","id":5268763,"node_id":"MDQ6VXNlcjUyNjg3NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/5268763?v=4","gravatar_id":"","url":"https://api.github.com/users/zz-jason","html_url":"https://github.com/zz-jason","followers_url":"https://api.github.com/users/zz-jason/followers","following_url":"https://api.github.com/users/zz-jason/following{/other_user}","gists_url":"https://api.github.com/users/zz-jason/gists{/gist_id}","starred_url":"https://api.github.com/users/zz-jason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz-jason/subscriptions","organizations_url":"https://api.github.com/users/zz-jason/orgs","repos_url":"https://api.github.com/users/zz-jason/repos","events_url":"https://api.github.com/users/zz-jason/events{/privacy}","received_events_url":"https://api.github.com/users/zz-jason/received_events","type":"User","site_admin":false},"body":"### What problem does this PR solve? <!--add issue link with summary if exists-->\r\n\r\nsupport framework of the cascades planner.\r\n\r\n### What is changed and how it works?\r\n\r\n~- introduce a global session variable \"tidb_enable_cascades_planner\" to control whether to use the cascades planner.~  split to https://github.com/pingcap/tidb/pull/7879 \r\n~- modify the `Optimize()` function to share some common code logic between the old planner and cascades planner.~  split to https://github.com/pingcap/tidb/pull/7879 \r\n~- implement the `Group` and `GroupExpr` component.~ split to https://github.com/pingcap/tidb/pull/7917\r\n\r\n- implement the `FindBestPlan()` function \r\n- implement the `convert2Group()` function to convert a logical plan to `Group`\r\n- implement the `onPhaseExploration()` function, which applies all the possible rules and transforms the expression to its equivalents.\r\n- implement the `ExprIter` to extract and iterate all the group expressions which match the rule pattern\r\n- modify the `GetOperand()` function to only return the operand.\r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n - Unit test **will be added later**\r\n\r\nCode changes\r\n\r\n - Has exported function/method change\r\n","created_at":"2018-10-11T03:23:51Z","updated_at":"2018-10-25T07:01:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5031cab467cf8cb469a1591f45b49341c6500052","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":667671533,"node_id":"MDU6TGFiZWw2Njc2NzE1MzM=","url":"https://api.github.com/repos/pingcap/tidb/labels/component/planner","name":"component/planner","color":"1d76db","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/7869/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/7869/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/7869/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/099d16e3cfeb318173fdbeb2dfbd424083f24c93","head":{"label":"zz-jason:cascades/framework","ref":"cascades/framework","sha":"099d16e3cfeb318173fdbeb2dfbd424083f24c93","user":{"login":"zz-jason","id":5268763,"node_id":"MDQ6VXNlcjUyNjg3NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/5268763?v=4","gravatar_id":"","url":"https://api.github.com/users/zz-jason","html_url":"https://github.com/zz-jason","followers_url":"https://api.github.com/users/zz-jason/followers","following_url":"https://api.github.com/users/zz-jason/following{/other_user}","gists_url":"https://api.github.com/users/zz-jason/gists{/gist_id}","starred_url":"https://api.github.com/users/zz-jason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz-jason/subscriptions","organizations_url":"https://api.github.com/users/zz-jason/orgs","repos_url":"https://api.github.com/users/zz-jason/repos","events_url":"https://api.github.com/users/zz-jason/events{/privacy}","received_events_url":"https://api.github.com/users/zz-jason/received_events","type":"User","site_admin":false},"repo":{"id":107492543,"node_id":"MDEwOlJlcG9zaXRvcnkxMDc0OTI1NDM=","name":"tidb","full_name":"zz-jason/tidb","private":false,"owner":{"login":"zz-jason","id":5268763,"node_id":"MDQ6VXNlcjUyNjg3NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/5268763?v=4","gravatar_id":"","url":"https://api.github.com/users/zz-jason","html_url":"https://github.com/zz-jason","followers_url":"https://api.github.com/users/zz-jason/followers","following_url":"https://api.github.com/users/zz-jason/following{/other_user}","gists_url":"https://api.github.com/users/zz-jason/gists{/gist_id}","starred_url":"https://api.github.com/users/zz-jason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zz-jason/subscriptions","organizations_url":"https://api.github.com/users/zz-jason/orgs","repos_url":"https://api.github.com/users/zz-jason/repos","events_url":"https://api.github.com/users/zz-jason/events{/privacy}","received_events_url":"https://api.github.com/users/zz-jason/received_events","type":"User","site_admin":false},"html_url":"https://github.com/zz-jason/tidb","description":"TiDB is a distributed NewSQL database compatible with MySQL protocol ","fork":true,"url":"https://api.github.com/repos/zz-jason/tidb","forks_url":"https://api.github.com/repos/zz-jason/tidb/forks","keys_url":"https://api.github.com/repos/zz-jason/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zz-jason/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zz-jason/tidb/teams","hooks_url":"https://api.github.com/repos/zz-jason/tidb/hooks","issue_events_url":"https://api.github.com/repos/zz-jason/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/zz-jason/tidb/events","assignees_url":"https://api.github.com/repos/zz-jason/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/zz-jason/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/zz-jason/tidb/tags","blobs_url":"https://api.github.com/repos/zz-jason/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zz-jason/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zz-jason/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/zz-jason/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zz-jason/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/zz-jason/tidb/languages","stargazers_url":"https://api.github.com/repos/zz-jason/tidb/stargazers","contributors_url":"https://api.github.com/repos/zz-jason/tidb/contributors","subscribers_url":"https://api.github.com/repos/zz-jason/tidb/subscribers","subscription_url":"https://api.github.com/repos/zz-jason/tidb/subscription","commits_url":"https://api.github.com/repos/zz-jason/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/zz-jason/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/zz-jason/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/zz-jason/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/zz-jason/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/zz-jason/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zz-jason/tidb/merges","archive_url":"https://api.github.com/repos/zz-jason/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zz-jason/tidb/downloads","issues_url":"https://api.github.com/repos/zz-jason/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/zz-jason/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/zz-jason/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/zz-jason/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zz-jason/tidb/labels{/name}","releases_url":"https://api.github.com/repos/zz-jason/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/zz-jason/tidb/deployments","created_at":"2017-10-19T03:14:19Z","updated_at":"2018-10-22T05:02:55Z","pushed_at":"2018-10-24T12:59:18Z","git_url":"git://github.com/zz-jason/tidb.git","ssh_url":"git@github.com:zz-jason/tidb.git","clone_url":"https://github.com/zz-jason/tidb.git","svn_url":"https://github.com/zz-jason/tidb","homepage":"https://pingcap.com","size":56921,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"pingcap:master","ref":"master","sha":"d65ce8655cd26bb5ec44f9239562013af692d2fa","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"node_id":"MDEwOlJlcG9zaXRvcnk0MTk4NjM2OQ==","name":"tidb","full_name":"pingcap/tidb","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb/deployments","created_at":"2015-09-06T04:01:52Z","updated_at":"2018-10-25T06:43:37Z","pushed_at":"2018-10-25T06:59:23Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"https://pingcap.com","size":84953,"stargazers_count":15487,"watchers_count":15487,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2199,"mirror_url":null,"archived":false,"open_issues_count":575,"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":2199,"open_issues":575,"watchers":15487,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7869"},"html":{"href":"https://github.com/pingcap/tidb/pull/7869"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7869"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7869/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7869/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7869/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/099d16e3cfeb318173fdbeb2dfbd424083f24c93"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"zz-jason"}}