@Override public boolean hasBuffer() { if (this.getElements().size() == this.getChildren()[0].getElements().size()) { return true; } return false; }
@Override public boolean hasBuffer() { if (this.getElements().size() == this.getChildren()[0].getElements().size()) { return true; } return false; }
@Override public boolean hasBuffer() { if (this.getElements().size() == this.getChildren()[0].getElements().size()) { return true; } return false; }
private TupleBatch outputPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (!this.output.isFinal()) { this.phase = SORT; } else if (!usingOutput) { this.output.setForwardOnly(true); } List<?> tuple = null; try { while ((tuple = this.outputTs.nextTuple()) != null) { //resize to remove unrelated columns if (this.getElements().size() < tuple.size()) { tuple = new ArrayList<Object>(tuple.subList(0, this.getElements().size())); } addBatchRow(tuple); if (this.isBatchFull()) { return pullBatch(); } } } catch (BlockedException e) { if (this.hasPendingRows()) { return this.pullBatch(); } throw e; } this.terminateBatches(); return this.pullBatch(); }
private TupleBatch outputPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (!this.output.isFinal()) { this.phase = SORT; } else if (!usingOutput) { this.output.setForwardOnly(true); } List<?> tuple = null; try { while ((tuple = this.outputTs.nextTuple()) != null) { //resize to remove unrelated columns if (this.getElements().size() < tuple.size()) { tuple = new ArrayList<Object>(tuple.subList(0, this.getElements().size())); } addBatchRow(tuple); if (this.isBatchFull()) { return pullBatch(); } } } catch (BlockedException e) { if (this.hasPendingRows()) { return this.pullBatch(); } throw e; } this.terminateBatches(); return this.pullBatch(); }
private TupleBatch outputPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException { if (!this.output.isFinal()) { this.phase = SORT; } else if (!usingOutput) { this.output.setForwardOnly(true); } List<?> tuple = null; try { while ((tuple = this.outputTs.nextTuple()) != null) { //resize to remove unrelated columns if (this.getElements().size() < tuple.size()) { tuple = new ArrayList<Object>(tuple.subList(0, this.getElements().size())); } addBatchRow(tuple); if (this.isBatchFull()) { return pullBatch(); } } } catch (BlockedException e) { if (this.hasPendingRows()) { return this.pullBatch(); } throw e; } this.terminateBatches(); return this.pullBatch(); }
@Test public void testSortAliasWithSameName() throws Exception { String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x order by e1"; //$NON-NLS-1$ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ SortNode node = (SortNode)plan.getRootNode(); assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol())); //$NON-NLS-1$ }
@Test public void testSortAliasWithSameNameUnion() throws Exception { String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x union all select e1 from pm1.g2 order by e1"; //$NON-NLS-1$ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder(); BasicSourceCapabilities caps = new BasicSourceCapabilities(); caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true); capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ SortNode node = (SortNode)plan.getRootNode(); assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol())); //$NON-NLS-1$ }