{"action":"created","comment":{"url":"https://api.github.com/repos/apache/phoenix/pulls/comments/25924146","id":25924146,"diff_hunk":"@@ -147,21 +169,146 @@ public QueryCompiler(PhoenixStatement statement, SelectStatement select, ColumnR\n      */\n     public QueryPlan compile() throws SQLException{\n         SelectStatement select = this.select;\n-        List<Object> binds = statement.getParameters();\n+        QueryPlan plan;\n+        if (isUnionAll()) {\n+            plan = compileUnionAll(select);\n+        } else {\n+            plan = compileSelect(select);\n+        }\n+        return plan;\n+    }\n+\n+    public QueryPlan compileSelect(SelectStatement select) throws SQLException{\n+     //   SelectStatement select = this.select;\n+    \tList<Object> binds = statement.getParameters();\n+    \tStatementContext context = new StatementContext(statement, resolver, scan, sequenceManager);\n+    \tColumnResolver resolver;\n+    \tif (isUnionAll()) {\n+    \t\tresolver = FromCompiler.getResolverForQuery(select, statement.getConnection());\n+    \t\tcontext = new StatementContext(statement, resolver, new Scan(), sequenceManager);\n+    \t} \n+    \tif (select.isJoin()) {\n+    \t\tif (isUnionAll()) {\n+    \t\t\tresolver = FromCompiler.getResolverForQuery(select, statement.getConnection());\n+    \t\t\tselect = JoinCompiler.optimize(statement, select, resolver);\n+    \t\t}\n+    \t\telse { \n+    \t\t    select = JoinCompiler.optimize(statement, select, this.resolver);\n+    \t\t}\n+    \t\tif (this.select != select) {\n+    \t\t    ColumnResolver resolver1 = FromCompiler.getResolverForQuery(select, statement.getConnection());\n+    \t\t    context = new StatementContext(statement, resolver1, scan, sequenceManager);\n+    \t\t}\n+    \t\tJoinTable joinTable = JoinCompiler.compile(statement, select, context.getResolver());\n+    \t\treturn compileJoinQuery(context, binds, joinTable, false, false, null);\n+    \t} else {\n+    \t    return compileSingleQuery(context, select, binds, false, true);\n+    \t}\n+    }\n+\n+    private void checkForOrderByLimitInUnionAllSelect(SelectStatement select) throws SQLException {\n+        if (select.getOrderBy() != null && !select.getOrderBy().isEmpty()) {\n+            throw new SQLExceptionInfo.Builder(SQLExceptionCode.ORDER_BY_IN_UNIONALL_SELECT_NOT_SUPPORTED).setMessage(\".\").build().buildException();\n+        }\n+        if (select.getLimit() != null) {\n+            throw new SQLExceptionInfo.Builder(SQLExceptionCode.LIMIT_IN_UNIONALL_SELECT_NOT_SUPPORTED).setMessage(\".\").build().buildException();\n+        }\n+    }\n+\n+    private PTable createTempTableForUnionAllResultResolver(QueryPlan plan) throws SQLException {","path":"phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java","position":136,"original_position":136,"commit_id":"2dc8c3612b98ee14034da4d04998d9f26da8b835","original_commit_id":"2dc8c3612b98ee14034da4d04998d9f26da8b835","user":{"login":"maryannxue","id":4171904,"avatar_url":"https://avatars.githubusercontent.com/u/4171904?v=3","gravatar_id":"","url":"https://api.github.com/users/maryannxue","html_url":"https://github.com/maryannxue","followers_url":"https://api.github.com/users/maryannxue/followers","following_url":"https://api.github.com/users/maryannxue/following{/other_user}","gists_url":"https://api.github.com/users/maryannxue/gists{/gist_id}","starred_url":"https://api.github.com/users/maryannxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maryannxue/subscriptions","organizations_url":"https://api.github.com/users/maryannxue/orgs","repos_url":"https://api.github.com/users/maryannxue/repos","events_url":"https://api.github.com/users/maryannxue/events{/privacy}","received_events_url":"https://api.github.com/users/maryannxue/received_events","type":"User","site_admin":false},"body":"The implementation is pretty good, but should be called elsewhere. Please refer to the comment below.","created_at":"2015-03-06T03:45:14Z","updated_at":"2015-03-06T03:45:14Z","html_url":"https://github.com/apache/phoenix/pull/39#discussion_r25924146","pull_request_url":"https://api.github.com/repos/apache/phoenix/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments/25924146"},"html":{"href":"https://github.com/apache/phoenix/pull/39#discussion_r25924146"},"pull_request":{"href":"https://api.github.com/repos/apache/phoenix/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/apache/phoenix/pulls/39","id":30600063,"html_url":"https://github.com/apache/phoenix/pull/39","diff_url":"https://github.com/apache/phoenix/pull/39.diff","patch_url":"https://github.com/apache/phoenix/pull/39.patch","issue_url":"https://api.github.com/repos/apache/phoenix/issues/39","number":39,"state":"open","locked":false,"title":"Phoenix-1580 union all impl","user":{"login":"ayingshu","id":8886070,"avatar_url":"https://avatars.githubusercontent.com/u/8886070?v=3","gravatar_id":"","url":"https://api.github.com/users/ayingshu","html_url":"https://github.com/ayingshu","followers_url":"https://api.github.com/users/ayingshu/followers","following_url":"https://api.github.com/users/ayingshu/following{/other_user}","gists_url":"https://api.github.com/users/ayingshu/gists{/gist_id}","starred_url":"https://api.github.com/users/ayingshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayingshu/subscriptions","organizations_url":"https://api.github.com/users/ayingshu/orgs","repos_url":"https://api.github.com/users/ayingshu/repos","events_url":"https://api.github.com/users/ayingshu/events{/privacy}","received_events_url":"https://api.github.com/users/ayingshu/received_events","type":"User","site_admin":false},"body":"Implementation using wrapped TupleProjectionPlan. My own implementation of association RowProjector with ResultIterator was commented out in code. ","created_at":"2015-03-05T22:00:23Z","updated_at":"2015-03-06T03:45:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67d358bffd3f7ab4df696997fb79192786abdf9d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/phoenix/pulls/39/commits","review_comments_url":"https://api.github.com/repos/apache/phoenix/pulls/39/comments","review_comment_url":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/phoenix/issues/39/comments","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/2dc8c3612b98ee14034da4d04998d9f26da8b835","head":{"label":"ayingshu:unionall","ref":"unionall","sha":"2dc8c3612b98ee14034da4d04998d9f26da8b835","user":{"login":"ayingshu","id":8886070,"avatar_url":"https://avatars.githubusercontent.com/u/8886070?v=3","gravatar_id":"","url":"https://api.github.com/users/ayingshu","html_url":"https://github.com/ayingshu","followers_url":"https://api.github.com/users/ayingshu/followers","following_url":"https://api.github.com/users/ayingshu/following{/other_user}","gists_url":"https://api.github.com/users/ayingshu/gists{/gist_id}","starred_url":"https://api.github.com/users/ayingshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayingshu/subscriptions","organizations_url":"https://api.github.com/users/ayingshu/orgs","repos_url":"https://api.github.com/users/ayingshu/repos","events_url":"https://api.github.com/users/ayingshu/events{/privacy}","received_events_url":"https://api.github.com/users/ayingshu/received_events","type":"User","site_admin":false},"repo":{"id":31620587,"name":"phoenix","full_name":"ayingshu/phoenix","owner":{"login":"ayingshu","id":8886070,"avatar_url":"https://avatars.githubusercontent.com/u/8886070?v=3","gravatar_id":"","url":"https://api.github.com/users/ayingshu","html_url":"https://github.com/ayingshu","followers_url":"https://api.github.com/users/ayingshu/followers","following_url":"https://api.github.com/users/ayingshu/following{/other_user}","gists_url":"https://api.github.com/users/ayingshu/gists{/gist_id}","starred_url":"https://api.github.com/users/ayingshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayingshu/subscriptions","organizations_url":"https://api.github.com/users/ayingshu/orgs","repos_url":"https://api.github.com/users/ayingshu/repos","events_url":"https://api.github.com/users/ayingshu/events{/privacy}","received_events_url":"https://api.github.com/users/ayingshu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ayingshu/phoenix","description":"Mirror of Apache Phoenix","fork":true,"url":"https://api.github.com/repos/ayingshu/phoenix","forks_url":"https://api.github.com/repos/ayingshu/phoenix/forks","keys_url":"https://api.github.com/repos/ayingshu/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ayingshu/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ayingshu/phoenix/teams","hooks_url":"https://api.github.com/repos/ayingshu/phoenix/hooks","issue_events_url":"https://api.github.com/repos/ayingshu/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/ayingshu/phoenix/events","assignees_url":"https://api.github.com/repos/ayingshu/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/ayingshu/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/ayingshu/phoenix/tags","blobs_url":"https://api.github.com/repos/ayingshu/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ayingshu/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ayingshu/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/ayingshu/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ayingshu/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/ayingshu/phoenix/languages","stargazers_url":"https://api.github.com/repos/ayingshu/phoenix/stargazers","contributors_url":"https://api.github.com/repos/ayingshu/phoenix/contributors","subscribers_url":"https://api.github.com/repos/ayingshu/phoenix/subscribers","subscription_url":"https://api.github.com/repos/ayingshu/phoenix/subscription","commits_url":"https://api.github.com/repos/ayingshu/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/ayingshu/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/ayingshu/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/ayingshu/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/ayingshu/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/ayingshu/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ayingshu/phoenix/merges","archive_url":"https://api.github.com/repos/ayingshu/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ayingshu/phoenix/downloads","issues_url":"https://api.github.com/repos/ayingshu/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/ayingshu/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/ayingshu/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/ayingshu/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ayingshu/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/ayingshu/phoenix/releases{/id}","created_at":"2015-03-03T20:50:03Z","updated_at":"2015-03-03T20:50:06Z","pushed_at":"2015-03-05T21:38:47Z","git_url":"git://github.com/ayingshu/phoenix.git","ssh_url":"git@github.com:ayingshu/phoenix.git","clone_url":"https://github.com/ayingshu/phoenix.git","svn_url":"https://github.com/ayingshu/phoenix","homepage":null,"size":23268,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"9a546b9c89a3920345ea35ad503dfb360d4c34a5","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":20473418,"name":"phoenix","full_name":"apache/phoenix","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/phoenix","description":"Mirror of Apache Phoenix","fork":false,"url":"https://api.github.com/repos/apache/phoenix","forks_url":"https://api.github.com/repos/apache/phoenix/forks","keys_url":"https://api.github.com/repos/apache/phoenix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/phoenix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/phoenix/teams","hooks_url":"https://api.github.com/repos/apache/phoenix/hooks","issue_events_url":"https://api.github.com/repos/apache/phoenix/issues/events{/number}","events_url":"https://api.github.com/repos/apache/phoenix/events","assignees_url":"https://api.github.com/repos/apache/phoenix/assignees{/user}","branches_url":"https://api.github.com/repos/apache/phoenix/branches{/branch}","tags_url":"https://api.github.com/repos/apache/phoenix/tags","blobs_url":"https://api.github.com/repos/apache/phoenix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/phoenix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/phoenix/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/phoenix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/phoenix/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/phoenix/languages","stargazers_url":"https://api.github.com/repos/apache/phoenix/stargazers","contributors_url":"https://api.github.com/repos/apache/phoenix/contributors","subscribers_url":"https://api.github.com/repos/apache/phoenix/subscribers","subscription_url":"https://api.github.com/repos/apache/phoenix/subscription","commits_url":"https://api.github.com/repos/apache/phoenix/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/phoenix/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/phoenix/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/phoenix/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/phoenix/contents/{+path}","compare_url":"https://api.github.com/repos/apache/phoenix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/phoenix/merges","archive_url":"https://api.github.com/repos/apache/phoenix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/phoenix/downloads","issues_url":"https://api.github.com/repos/apache/phoenix/issues{/number}","pulls_url":"https://api.github.com/repos/apache/phoenix/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/phoenix/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/phoenix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/phoenix/labels{/name}","releases_url":"https://api.github.com/repos/apache/phoenix/releases{/id}","created_at":"2014-06-04T07:00:08Z","updated_at":"2015-03-06T00:48:27Z","pushed_at":"2015-03-06T01:00:07Z","git_url":"git://github.com/apache/phoenix.git","ssh_url":"git@github.com:apache/phoenix.git","clone_url":"https://github.com/apache/phoenix.git","svn_url":"https://github.com/apache/phoenix","homepage":null,"size":23268,"stargazers_count":44,"watchers_count":44,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":76,"mirror_url":"git://git.apache.org/phoenix.git","open_issues_count":24,"forks":76,"open_issues":24,"watchers":44,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/phoenix/pulls/39"},"html":{"href":"https://github.com/apache/phoenix/pull/39"},"issue":{"href":"https://api.github.com/repos/apache/phoenix/issues/39"},"comments":{"href":"https://api.github.com/repos/apache/phoenix/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/phoenix/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/phoenix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/phoenix/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/apache/phoenix/statuses/2dc8c3612b98ee14034da4d04998d9f26da8b835"}}}}