[ https://issues.apache.org/jira/browse/PHOENIX-1580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14387235#comment-14387235 ]
Alicia Ying Shu edited comment on PHOENIX-1580 at 3/30/15 7:11 PM: ------------------------------------------------------------------- [~jamestaylor] Here is the code that using MergeSortTopNResultIterator in UnionPlan.java that did not work. It returned Null result. I think it is due to we wrapped the plan with TupleProjector which is not a real table. public final ResultIterator iterator(final List<? extends SQLCloseable> dependencies) throws SQLException { ResultIterator scanner; ResultIterators iterators; boolean allowPageFilter = false; boolean isOrdered = (orderBy != null) && !orderBy.getOrderByExpressions().isEmpty(); Integer perScanLimit = !allowPageFilter || isOrdered ? null : limit; List<PeekingResultIterator> pIterators = new ArrayList<PeekingResultIterator>(); for (QueryPlan plan : this.getPlans()) { if (isOrdered) { iterators = new ParallelIterators(plan, perScanLimit, parallelIteratorFactory); scanner = new MergeSortTopNResultIterator(iterators, limit, orderBy.getOrderByExpressions()); pIterators.add(LookAheadResultIterator.wrap(scanner)); } else { pIterators.add(LookAheadResultIterator.wrap(plan.iterator())); } } scanner = new ConcatResultIterator(pIterators); if (isOrdered) { // TopN int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); scanner = new OrderedResultIterator(scanner, orderBy.getOrderByExpressions(), thresholdBytes, limit, this.getProjector().getEstimatedRowByteSize()); } else if (limit != null) { scanner = new LimitingResultIterator(scanner, limit); } if (context.getSequenceManager().getSequenceCount() > 0) { scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); } return scanner; } was (Author: aliciashu): [~jamestaylor] Here is the code that using MergeSortTopNResultIterator in UnionPlan.java that did not work. It returned Null result. I think it is due to we wrapped the plan with TupleProjector which is not a real table. public final ResultIterator iterator(final List<? extends SQLCloseable> dependencies) throws SQLException { ResultIterator scanner; ResultIterators iterators; boolean allowPageFilter = false; boolean isOrdered = (orderBy != null) && !orderBy.getOrderByExpressions().isEmpty(); Integer perScanLimit = !allowPageFilter || isOrdered ? null : limit; List<PeekingResultIterator> pIterators = new ArrayList<PeekingResultIterator>(); for (QueryPlan plan : this.getPlans()) { if (isOrdered) { iterators = new ParallelIterators(plan, perScanLimit, parallelIteratorFactory); scanner = new MergeSortTopNResultIterator(iterators, limit, orderBy.getOrderByExpressions()); pIterators.add(LookAheadResultIterator.wrap(scanner)); } else { pIterators.add(LookAheadResultIterator.wrap(plan.iterator())); } } scanner = new ConcatResultIterator(pIterators); if (isOrdered) { // TopN int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); scanner = new OrderedResultIterator(scanner, orderBy.getOrderByExpressions(), thresholdBytes, limit, this.getProjector().getEstimatedRowByteSize()); } else if (limit != null) { scanner = new LimitingResultIterator(scanner, limit); } if (context.getSequenceManager().getSequenceCount() > 0) { scanner = new SequenceResultIterator(scanner, context.getSequenceManager()); } return scanner; } > Support UNION ALL > ----------------- > > Key: PHOENIX-1580 > URL: https://issues.apache.org/jira/browse/PHOENIX-1580 > Project: Phoenix > Issue Type: Bug > Reporter: Alicia Ying Shu > Assignee: Alicia Ying Shu > Attachments: PHOENIX-1580-grammar.patch, Phoenix-1580-v1.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)