Return-Path: X-Original-To: apmail-phoenix-dev-archive@minotaur.apache.org Delivered-To: apmail-phoenix-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BD1DB1755D for ; Sat, 4 Apr 2015 02:27:56 +0000 (UTC) Received: (qmail 64653 invoked by uid 500); 4 Apr 2015 02:27:56 -0000 Delivered-To: apmail-phoenix-dev-archive@phoenix.apache.org Received: (qmail 64598 invoked by uid 500); 4 Apr 2015 02:27:56 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 64587 invoked by uid 99); 4 Apr 2015 02:27:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Apr 2015 02:27:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 04 Apr 2015 02:27:55 +0000 Received: (qmail 64200 invoked by uid 99); 4 Apr 2015 02:27:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Apr 2015 02:27:34 +0000 Date: Sat, 4 Apr 2015 02:27:34 +0000 (UTC) From: "Maryann Xue (JIRA)" To: dev@phoenix.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PHOENIX-1580) Support UNION ALL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/PHOENIX-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14395476#comment-14395476 ] Maryann Xue commented on PHOENIX-1580: -------------------------------------- This is what I put in ParseNodeFactory.select(), very simple straight-forward steps: {code} + public SelectStatement select(List statements, List orderBy, LimitNode limit, int bindCount) { + if (statements.size() == 1) + return statements.get(0); + + return select(null, HintNode.EMPTY_HINT_NODE, false, Lists.newArrayList(aliasedNode(null, wildcard())), + null, null, null, null, limit, bindCount, false, false, statements); + } + {code} And this is what compiler does for ORDER-BY and LIMIT push down: {code} + public QueryPlan compileUnionAll(SelectStatement select) throws SQLException { + List unionAllSelects = select.getSelects(); + List plans = new ArrayList(); + + int numSelects = unionAllSelects.size(); + for (int i=0; i < numSelects; i++ ) { + SelectStatement subSelect = unionAllSelects.get(i); + // Push down order-by and limit into sub-selects. + if (!select.getOrderBy().isEmpty() || select.getLimit() != null) { + subSelect = NODE_FACTORY.select(subSelect, select.getOrderBy(), select.getLimit()); + } + QueryPlan subPlan = compileSubquery(subSelect); + TupleProjector projector = new TupleProjector(subPlan.getProjector()); + subPlan = new TupleProjectionPlan(subPlan, projector, null); + plans.add(subPlan); + } + UnionCompiler.checkProjectionNumAndTypes(plans); + + TableRef tableRef = UnionCompiler.contructSchemaTable(statement, plans.get(0)); + ColumnResolver resolver = FromCompiler.getResolver(tableRef); + StatementContext context = new StatementContext(statement, resolver, scan, sequenceManager); + + QueryPlan plan = compileSingleFlatQuery(context, select, statement.getParameters(), false, false, null, null, false); + plan = new UnionPlan(context, select, tableRef, plan.getProjector(), plan.getLimit(), plan.getOrderBy(), GroupBy.EMPTY_GROUP_BY, plans, null); + return plan; + } {code} > Support UNION ALL > ----------------- > > Key: PHOENIX-1580 > URL: https://issues.apache.org/jira/browse/PHOENIX-1580 > Project: Phoenix > Issue Type: Improvement > Reporter: Alicia Ying Shu > Assignee: Alicia Ying Shu > Attachments: PHOENIX-1580-grammar.patch, Phoenix-1580-v1.patch, Phoenix-1580-v2.patch, Phoenix-1580-v3.patch, Phoenix-1580-v4.patch, Phoenix-1580-v5.patch, Phoenix-1580-v6.patch, Phoenix-1580-v7.patch, Phoenix-1580-v8.patch, phoenix-1580-v1-wipe.patch, phoenix-1580.patch, unionall-wipe.patch > > > Select * from T1 > UNION ALL > Select * from T2 -- This message was sent by Atlassian JIRA (v6.3.4#6332)