{"action":"created","comment":{"url":"https://api.github.com/repos/apache/beam/pulls/comments/193479308","pull_request_review_id":126456673,"id":193479308,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzQ3OTMwOA==","diff_hunk":"@@ -503,13 +513,32 @@ private static boolean isDateNode(SqlTypeName type, Object value) {\n   public void prepare() {}\n \n   @Override\n-  public List<Object> execute(\n-      Row inputRow, BoundedWindow window, ImmutableMap<Integer, Object> correlateEnv) {\n-    List<Object> results = new ArrayList<>();\n-    for (BeamSqlExpression exp : exps) {\n-      results.add(exp.evaluate(inputRow, window, correlateEnv).getValue());\n+  public @Nullable List<Object> execute(\n+      Row inputRow, BoundedWindow window, BeamSqlExpressionEnvironment env) {\n+\n+    final BeamSqlExpressionEnvironment finalEnv = buildExprEnv(inputRow, window, env);\n+\n+    boolean conditionResult = filterCondition.evaluate(inputRow, window, finalEnv).getBoolean();\n+\n+    if (conditionResult) {\n+      return projections\n+          .stream()\n+          .map(project -> project.evaluate(inputRow, window, finalEnv).getValue())\n+          .collect(Collectors.toList());\n+    } else {\n+      return null;\n+    }\n+  }\n+\n+  private BeamSqlExpressionEnvironment buildExprEnv(\n+      Row inputRow, BoundedWindow window, BeamSqlExpressionEnvironment env) {\n+    int nextExprId = 0;\n+    BeamSqlExpressionEnvironment localEnv = env.copyWithEmptyLocalRefs(exprs.size());\n+    for (BeamSqlExpression expr : exprs) {\n+      localEnv.setLocalRef(nextExprId, expr.evaluate(inputRow, window, localEnv));","path":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/interpreter/BeamSqlFnExecutor.java","position":130,"original_position":130,"commit_id":"8cc0a8d797eafd0c2c634a6b55124d040ef2d17d","original_commit_id":"8cc0a8d797eafd0c2c634a6b55124d040ef2d17d","user":{"login":"akedin","id":33067037,"node_id":"MDQ6VXNlcjMzMDY3MDM3","avatar_url":"https://avatars0.githubusercontent.com/u/33067037?v=4","gravatar_id":"","url":"https://api.github.com/users/akedin","html_url":"https://github.com/akedin","followers_url":"https://api.github.com/users/akedin/followers","following_url":"https://api.github.com/users/akedin/following{/other_user}","gists_url":"https://api.github.com/users/akedin/gists{/gist_id}","starred_url":"https://api.github.com/users/akedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akedin/subscriptions","organizations_url":"https://api.github.com/users/akedin/orgs","repos_url":"https://api.github.com/users/akedin/repos","events_url":"https://api.github.com/users/akedin/events{/privacy}","received_events_url":"https://api.github.com/users/akedin/received_events","type":"User","site_admin":false},"body":"should the evaluation be lazy performed at access time?","created_at":"2018-06-06T16:42:01Z","updated_at":"2018-06-06T16:47:11Z","html_url":"https://github.com/apache/beam/pull/5544#discussion_r193479308","pull_request_url":"https://api.github.com/repos/apache/beam/pulls/5544","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/comments/193479308"},"html":{"href":"https://github.com/apache/beam/pull/5544#discussion_r193479308"},"pull_request":{"href":"https://api.github.com/repos/apache/beam/pulls/5544"}}},"pull_request":{"url":"https://api.github.com/repos/apache/beam/pulls/5544","id":192209953,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMjA5OTUz","html_url":"https://github.com/apache/beam/pull/5544","diff_url":"https://github.com/apache/beam/pull/5544.diff","patch_url":"https://github.com/apache/beam/pull/5544.patch","issue_url":"https://api.github.com/repos/apache/beam/issues/5544","number":5544,"state":"open","locked":false,"title":"[BEAM-4449] Replace project and filter with calc","user":{"login":"kennknowles","id":575353,"node_id":"MDQ6VXNlcjU3NTM1Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/575353?v=4","gravatar_id":"","url":"https://api.github.com/users/kennknowles","html_url":"https://github.com/kennknowles","followers_url":"https://api.github.com/users/kennknowles/followers","following_url":"https://api.github.com/users/kennknowles/following{/other_user}","gists_url":"https://api.github.com/users/kennknowles/gists{/gist_id}","starred_url":"https://api.github.com/users/kennknowles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennknowles/subscriptions","organizations_url":"https://api.github.com/users/kennknowles/orgs","repos_url":"https://api.github.com/users/kennknowles/repos","events_url":"https://api.github.com/users/kennknowles/events{/privacy}","received_events_url":"https://api.github.com/users/kennknowles/received_events","type":"User","site_admin":false},"body":"This replaces Project and Filter with the compound operation Calc. This is easier to optimize and centralizes the changes we have to make in order to switch from our interpreter to Calcite's (or other) code gen.\r\n\r\n------------------------\r\n\r\nFollow this checklist to help us incorporate your contribution quickly and easily:\r\n\r\n - [x] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.\r\n - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).\r\n\r\nIt will help us expedite review of your Pull Request if you tag someone (e.g. `@username`) to look at it.\r\n","created_at":"2018-06-02T17:58:03Z","updated_at":"2018-06-06T16:47:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a05380636da1ef241bbddb8ee4830a33a1c92cd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/beam/pulls/5544/commits","review_comments_url":"https://api.github.com/repos/apache/beam/pulls/5544/comments","review_comment_url":"https://api.github.com/repos/apache/beam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/beam/issues/5544/comments","statuses_url":"https://api.github.com/repos/apache/beam/statuses/8cc0a8d797eafd0c2c634a6b55124d040ef2d17d","head":{"label":"kennknowles:calc","ref":"calc","sha":"8cc0a8d797eafd0c2c634a6b55124d040ef2d17d","user":{"login":"kennknowles","id":575353,"node_id":"MDQ6VXNlcjU3NTM1Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/575353?v=4","gravatar_id":"","url":"https://api.github.com/users/kennknowles","html_url":"https://github.com/kennknowles","followers_url":"https://api.github.com/users/kennknowles/followers","following_url":"https://api.github.com/users/kennknowles/following{/other_user}","gists_url":"https://api.github.com/users/kennknowles/gists{/gist_id}","starred_url":"https://api.github.com/users/kennknowles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennknowles/subscriptions","organizations_url":"https://api.github.com/users/kennknowles/orgs","repos_url":"https://api.github.com/users/kennknowles/repos","events_url":"https://api.github.com/users/kennknowles/events{/privacy}","received_events_url":"https://api.github.com/users/kennknowles/received_events","type":"User","site_admin":false},"repo":{"id":52646147,"node_id":"MDEwOlJlcG9zaXRvcnk1MjY0NjE0Nw==","name":"beam","full_name":"kennknowles/beam","owner":{"login":"kennknowles","id":575353,"node_id":"MDQ6VXNlcjU3NTM1Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/575353?v=4","gravatar_id":"","url":"https://api.github.com/users/kennknowles","html_url":"https://github.com/kennknowles","followers_url":"https://api.github.com/users/kennknowles/followers","following_url":"https://api.github.com/users/kennknowles/following{/other_user}","gists_url":"https://api.github.com/users/kennknowles/gists{/gist_id}","starred_url":"https://api.github.com/users/kennknowles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennknowles/subscriptions","organizations_url":"https://api.github.com/users/kennknowles/orgs","repos_url":"https://api.github.com/users/kennknowles/repos","events_url":"https://api.github.com/users/kennknowles/events{/privacy}","received_events_url":"https://api.github.com/users/kennknowles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kennknowles/beam","description":"Mirror of Apache Beam (Incubating)","fork":true,"url":"https://api.github.com/repos/kennknowles/beam","forks_url":"https://api.github.com/repos/kennknowles/beam/forks","keys_url":"https://api.github.com/repos/kennknowles/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kennknowles/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kennknowles/beam/teams","hooks_url":"https://api.github.com/repos/kennknowles/beam/hooks","issue_events_url":"https://api.github.com/repos/kennknowles/beam/issues/events{/number}","events_url":"https://api.github.com/repos/kennknowles/beam/events","assignees_url":"https://api.github.com/repos/kennknowles/beam/assignees{/user}","branches_url":"https://api.github.com/repos/kennknowles/beam/branches{/branch}","tags_url":"https://api.github.com/repos/kennknowles/beam/tags","blobs_url":"https://api.github.com/repos/kennknowles/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kennknowles/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kennknowles/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/kennknowles/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kennknowles/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/kennknowles/beam/languages","stargazers_url":"https://api.github.com/repos/kennknowles/beam/stargazers","contributors_url":"https://api.github.com/repos/kennknowles/beam/contributors","subscribers_url":"https://api.github.com/repos/kennknowles/beam/subscribers","subscription_url":"https://api.github.com/repos/kennknowles/beam/subscription","commits_url":"https://api.github.com/repos/kennknowles/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/kennknowles/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/kennknowles/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/kennknowles/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/kennknowles/beam/contents/{+path}","compare_url":"https://api.github.com/repos/kennknowles/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kennknowles/beam/merges","archive_url":"https://api.github.com/repos/kennknowles/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kennknowles/beam/downloads","issues_url":"https://api.github.com/repos/kennknowles/beam/issues{/number}","pulls_url":"https://api.github.com/repos/kennknowles/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/kennknowles/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/kennknowles/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kennknowles/beam/labels{/name}","releases_url":"https://api.github.com/repos/kennknowles/beam/releases{/id}","deployments_url":"https://api.github.com/repos/kennknowles/beam/deployments","created_at":"2016-02-27T02:37:09Z","updated_at":"2017-01-03T20:56:46Z","pushed_at":"2018-06-06T15:21:20Z","git_url":"git://github.com/kennknowles/beam.git","ssh_url":"git@github.com:kennknowles/beam.git","clone_url":"https://github.com/kennknowles/beam.git","svn_url":"https://github.com/kennknowles/beam","homepage":null,"size":108106,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"5b9faa416059299d0fe442b67dea5b3c1cb3d83b","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":50904245,"node_id":"MDEwOlJlcG9zaXRvcnk1MDkwNDI0NQ==","name":"beam","full_name":"apache/beam","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},"private":false,"html_url":"https://github.com/apache/beam","description":"Apache Beam","fork":false,"url":"https://api.github.com/repos/apache/beam","forks_url":"https://api.github.com/repos/apache/beam/forks","keys_url":"https://api.github.com/repos/apache/beam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/beam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/beam/teams","hooks_url":"https://api.github.com/repos/apache/beam/hooks","issue_events_url":"https://api.github.com/repos/apache/beam/issues/events{/number}","events_url":"https://api.github.com/repos/apache/beam/events","assignees_url":"https://api.github.com/repos/apache/beam/assignees{/user}","branches_url":"https://api.github.com/repos/apache/beam/branches{/branch}","tags_url":"https://api.github.com/repos/apache/beam/tags","blobs_url":"https://api.github.com/repos/apache/beam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/beam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/beam/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/beam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/beam/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/beam/languages","stargazers_url":"https://api.github.com/repos/apache/beam/stargazers","contributors_url":"https://api.github.com/repos/apache/beam/contributors","subscribers_url":"https://api.github.com/repos/apache/beam/subscribers","subscription_url":"https://api.github.com/repos/apache/beam/subscription","commits_url":"https://api.github.com/repos/apache/beam/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/beam/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/beam/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/beam/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/beam/contents/{+path}","compare_url":"https://api.github.com/repos/apache/beam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/beam/merges","archive_url":"https://api.github.com/repos/apache/beam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/beam/downloads","issues_url":"https://api.github.com/repos/apache/beam/issues{/number}","pulls_url":"https://api.github.com/repos/apache/beam/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/beam/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/beam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/beam/labels{/name}","releases_url":"https://api.github.com/repos/apache/beam/releases{/id}","deployments_url":"https://api.github.com/repos/apache/beam/deployments","created_at":"2016-02-02T08:00:06Z","updated_at":"2018-06-06T08:17:18Z","pushed_at":"2018-06-06T15:54:53Z","git_url":"git://github.com/apache/beam.git","ssh_url":"git@github.com:apache/beam.git","clone_url":"https://github.com/apache/beam.git","svn_url":"https://github.com/apache/beam","homepage":"","size":64817,"stargazers_count":1898,"watchers_count":1898,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1177,"mirror_url":null,"archived":false,"open_issues_count":117,"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":1177,"open_issues":117,"watchers":1898,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/beam/pulls/5544"},"html":{"href":"https://github.com/apache/beam/pull/5544"},"issue":{"href":"https://api.github.com/repos/apache/beam/issues/5544"},"comments":{"href":"https://api.github.com/repos/apache/beam/issues/5544/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/beam/pulls/5544/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/beam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/beam/pulls/5544/commits"},"statuses":{"href":"https://api.github.com/repos/apache/beam/statuses/8cc0a8d797eafd0c2c634a6b55124d040ef2d17d"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"akedin"}}