{"action":"created","issue":{"url":"https://api.github.com/repos/src-d/go-mysql-server/issues/106","repository_url":"https://api.github.com/repos/src-d/go-mysql-server","labels_url":"https://api.github.com/repos/src-d/go-mysql-server/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/src-d/go-mysql-server/issues/106/comments","events_url":"https://api.github.com/repos/src-d/go-mysql-server/issues/106/events","html_url":"https://github.com/src-d/go-mysql-server/issues/106","id":305491582,"number":106,"title":"Add Walk function to plan","user":{"login":"erizocosmico","id":1312023,"avatar_url":"https://avatars1.githubusercontent.com/u/1312023?v=4","gravatar_id":"","url":"https://api.github.com/users/erizocosmico","html_url":"https://github.com/erizocosmico","followers_url":"https://api.github.com/users/erizocosmico/followers","following_url":"https://api.github.com/users/erizocosmico/following{/other_user}","gists_url":"https://api.github.com/users/erizocosmico/gists{/gist_id}","starred_url":"https://api.github.com/users/erizocosmico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erizocosmico/subscriptions","organizations_url":"https://api.github.com/users/erizocosmico/orgs","repos_url":"https://api.github.com/users/erizocosmico/repos","events_url":"https://api.github.com/users/erizocosmico/events{/privacy}","received_events_url":"https://api.github.com/users/erizocosmico/received_events","type":"User","site_admin":false},"labels":[{"id":844048792,"url":"https://api.github.com/repos/src-d/go-mysql-server/labels/proposal","name":"proposal","color":"fc8880","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-15T10:23:27Z","updated_at":"2018-03-15T11:06:15Z","closed_at":null,"author_association":"MEMBER","body":"# Problem\r\n\r\nWe have many rules in the analyzer that need to gather some data from the whole tree before making any transformations. To do that, right now they make use of `TransformUp`, which creates a lot of nodes that are unnecessary, since we are not transforming anything, just gathering data.\r\n\r\n# Solution\r\n\r\nIt would be very handy to have a `Walk` function in the plan that allowed us to traverse the plan nodes.\r\n\r\nWhy a function instead of a method? To not add more and more methods to the `Node` interface. Besides, we don't need all nodes to implement that, only the ones we care about. For example, we don't need table implementations to provide their `Walk` method. Plan nodes can only be generated by us, since we are the ones parsing.\r\n\r\nBesides, we have the `Children` method in the `Node` interface, which makes having a per-node implementation of `Walk` irrelevant.\r\n\r\nIdeal API would be the following:\r\n\r\n```go\r\nplan.Walk(node, func(sql.Node) plan.Visitor {\r\n        // do something with the node\r\n})\r\n```\r\n\r\nThe callback should return a `Visitor` with perhaps custom logic for the given node or nil to stop.\r\n\r\nThen the shortcut:\r\n\r\n```go\r\nplan.Inspect(node, func(sql.Node) bool {\r\n        // do something with the node\r\n})\r\n```\r\nThe callback should return a boolean. If the result is `true` it will stop walking.\r\n\r\nIt should work like [go/ast#Inspect](https://golang.org/pkg/go/ast/#Inspect) and [go/ast#Walk](https://golang.org/pkg/go/ast/#Walk) "},"comment":{"url":"https://api.github.com/repos/src-d/go-mysql-server/issues/comments/373339743","html_url":"https://github.com/src-d/go-mysql-server/issues/106#issuecomment-373339743","issue_url":"https://api.github.com/repos/src-d/go-mysql-server/issues/106","id":373339743,"user":{"login":"erizocosmico","id":1312023,"avatar_url":"https://avatars1.githubusercontent.com/u/1312023?v=4","gravatar_id":"","url":"https://api.github.com/users/erizocosmico","html_url":"https://github.com/erizocosmico","followers_url":"https://api.github.com/users/erizocosmico/followers","following_url":"https://api.github.com/users/erizocosmico/following{/other_user}","gists_url":"https://api.github.com/users/erizocosmico/gists{/gist_id}","starred_url":"https://api.github.com/users/erizocosmico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erizocosmico/subscriptions","organizations_url":"https://api.github.com/users/erizocosmico/orgs","repos_url":"https://api.github.com/users/erizocosmico/repos","events_url":"https://api.github.com/users/erizocosmico/events{/privacy}","received_events_url":"https://api.github.com/users/erizocosmico/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T11:06:15Z","updated_at":"2018-03-15T11:06:15Z","author_association":"MEMBER","body":"It can certainly wait.\r\nOn Thu, 15 Mar 2018 at 11:44, Antonio Navarro Perez <notifications@github.com<mailto:notifications@github.com>> wrote:\r\n\r\nGood idea!\r\n\r\nThis is needed for something pending right now?. If not, I would say to wait until the next version to implement it.\r\n\r\n—\r\nYou are receiving this because you authored the thread.\r\nReply to this email directly, view it on GitHub<https://github.com/src-d/go-mysql-server/issues/106#issuecomment-373334310>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABQFFxA5vahlMqAH5Jei_S0Iscgkcm8Wks5tekYlgaJpZM4Sr4wm>.\r\n"}}
{"actor":{"display_login":"erizocosmico"}}