{"action":"created","issue":{"url":"https://api.github.com/repos/prestodb/presto/issues/7780","repository_url":"https://api.github.com/repos/prestodb/presto","labels_url":"https://api.github.com/repos/prestodb/presto/issues/7780/labels{/name}","comments_url":"https://api.github.com/repos/prestodb/presto/issues/7780/comments","events_url":"https://api.github.com/repos/prestodb/presto/issues/7780/events","html_url":"https://github.com/prestodb/presto/issues/7780","id":220236356,"number":7780,"title":"Incorrect lambda analysis in aggregation context","user":{"login":"sopel39","id":5989165,"avatar_url":"https://avatars2.githubusercontent.com/u/5989165?v=3","gravatar_id":"","url":"https://api.github.com/users/sopel39","html_url":"https://github.com/sopel39","followers_url":"https://api.github.com/users/sopel39/followers","following_url":"https://api.github.com/users/sopel39/following{/other_user}","gists_url":"https://api.github.com/users/sopel39/gists{/gist_id}","starred_url":"https://api.github.com/users/sopel39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sopel39/subscriptions","organizations_url":"https://api.github.com/users/sopel39/orgs","repos_url":"https://api.github.com/users/sopel39/repos","events_url":"https://api.github.com/users/sopel39/events{/privacy}","received_events_url":"https://api.github.com/users/sopel39/received_events","type":"User","site_admin":false},"labels":[{"id":11191945,"url":"https://api.github.com/repos/prestodb/presto/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":{"login":"sopel39","id":5989165,"avatar_url":"https://avatars2.githubusercontent.com/u/5989165?v=3","gravatar_id":"","url":"https://api.github.com/users/sopel39","html_url":"https://github.com/sopel39","followers_url":"https://api.github.com/users/sopel39/followers","following_url":"https://api.github.com/users/sopel39/following{/other_user}","gists_url":"https://api.github.com/users/sopel39/gists{/gist_id}","starred_url":"https://api.github.com/users/sopel39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sopel39/subscriptions","organizations_url":"https://api.github.com/users/sopel39/orgs","repos_url":"https://api.github.com/users/sopel39/repos","events_url":"https://api.github.com/users/sopel39/events{/privacy}","received_events_url":"https://api.github.com/users/sopel39/received_events","type":"User","site_admin":false},"assignees":[{"login":"sopel39","id":5989165,"avatar_url":"https://avatars2.githubusercontent.com/u/5989165?v=3","gravatar_id":"","url":"https://api.github.com/users/sopel39","html_url":"https://github.com/sopel39","followers_url":"https://api.github.com/users/sopel39/followers","following_url":"https://api.github.com/users/sopel39/following{/other_user}","gists_url":"https://api.github.com/users/sopel39/gists{/gist_id}","starred_url":"https://api.github.com/users/sopel39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sopel39/subscriptions","organizations_url":"https://api.github.com/users/sopel39/orgs","repos_url":"https://api.github.com/users/sopel39/repos","events_url":"https://api.github.com/users/sopel39/events{/privacy}","received_events_url":"https://api.github.com/users/sopel39/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-04-07T14:48:21Z","updated_at":"2017-04-07T14:54:04Z","closed_at":null,"body":"```\r\npresto:sf1> select transform(array[1], x -> y + transform(array[1], z -> x)[1]) from (values (1, 2)) t(x,y) group by y + transform(array[1], z -> x)[1];\r\nQuery 20170407_142317_00009_bw2qq failed: Invalid node. Expression dependencies ([field_2]) not in source plan output ([expr_7, $hashvalue])\r\n```\r\n\r\n`LambdaReferenceExtractor` only searches at top level and doesn't visit nested lambdas. However, simply visiting nested lambdas won't fix the bug since we need to know that nested (capture) lambda argument reference comes from outer lambda. We can do this tracking in `LambdaReferenceExtractor`.\r\nHowever, we could imagine lambdas with captures within subqueries. In such case the tracking won't be feasible anymore. In the future, I think lambda argument resolution should use `Scope` and `FieldId` mechanism so that lambda and column references can be processed similarly.\r\n\r\nFYI: @martint @haozhun @findepi "},"comment":{"url":"https://api.github.com/repos/prestodb/presto/issues/comments/292558916","html_url":"https://github.com/prestodb/presto/issues/7780#issuecomment-292558916","issue_url":"https://api.github.com/repos/prestodb/presto/issues/7780","id":292558916,"user":{"login":"sopel39","id":5989165,"avatar_url":"https://avatars2.githubusercontent.com/u/5989165?v=3","gravatar_id":"","url":"https://api.github.com/users/sopel39","html_url":"https://github.com/sopel39","followers_url":"https://api.github.com/users/sopel39/followers","following_url":"https://api.github.com/users/sopel39/following{/other_user}","gists_url":"https://api.github.com/users/sopel39/gists{/gist_id}","starred_url":"https://api.github.com/users/sopel39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sopel39/subscriptions","organizations_url":"https://api.github.com/users/sopel39/orgs","repos_url":"https://api.github.com/users/sopel39/repos","events_url":"https://api.github.com/users/sopel39/events{/privacy}","received_events_url":"https://api.github.com/users/sopel39/received_events","type":"User","site_admin":false},"created_at":"2017-04-07T14:54:04Z","updated_at":"2017-04-07T14:54:04Z","body":"Additionally, `DefaultTraversalVisitor` doesn't have default visitor for lambda. When I tried adding one, lambda tests failed. Missing default visitor might not be a problem (for now), but it is inconsistent with other nodes (e.g: subquery node).\r\n\r\nMaybe `DefaultTraversalVisitor` should visit lambda body, while `DefaultExpressionTraversalVisitor` shouldn't (similar as for subqueries)? What do you think @haozhun "}}
{"actor":{"display_login":"sopel39"}}