Author: jolee
Date: 2013-10-08 15:41:59 -0400 (Tue, 08 Oct 2013)
New Revision: 4601
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
Log:
TEIID-2690: Tuples lost in a with clause item.
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
---
branches/7.7.x/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2013-10-04
20:57:36 UTC (rev 4600)
+++
branches/7.7.x/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2013-10-08
19:41:59 UTC (rev 4601)
@@ -48,6 +48,7 @@
import org.teiid.query.QueryPlugin;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.processor.BatchCollector;
import org.teiid.query.processor.BatchIterator;
import org.teiid.query.processor.QueryProcessor;
import org.teiid.query.resolver.command.TempTableResolver;
@@ -85,11 +86,13 @@
public static class TableProcessor {
QueryProcessor queryProcessor;
List<ElementSymbol> columns;
-
+ BatchIterator iterator;
+
public TableProcessor(QueryProcessor queryProcessor,
List<ElementSymbol> columns) {
this.queryProcessor = queryProcessor;
this.columns = columns;
+ this.iterator = new BatchIterator(queryProcessor);
}
public QueryProcessor getQueryProcessor() {
@@ -358,7 +361,7 @@
TableProcessor withProcessor, TempTable tempTable)
throws TeiidComponentException, ExpressionEvaluationException,
TeiidProcessingException {
- tempTable.insert(new BatchIterator(withProcessor.queryProcessor),
withProcessor.columns, false);
+ tempTable.insert(new
BatchCollector.BatchProducerTupleSource(withProcessor.queryProcessor),
withProcessor.columns, false);
tempTable.setUpdatable(false);
processors.remove(tempTableID);
}
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
---
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2013-10-04
20:57:36 UTC (rev 4600)
+++
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2013-10-08
19:41:59 UTC (rev 4601)
@@ -6,13 +6,20 @@
import java.util.List;
import org.junit.Test;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.sql.lang.Command;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
@SuppressWarnings({"nls", "unchecked"})
public class TestWithClauseProcessing {
@@ -193,4 +200,59 @@
helpProcess(plan, dataManager, new List[0]);
}
+
+ @Test public void testWithBlockingJoin() throws TeiidException {
+
+ String sql = "with a (x, y) as (select e1, e2 from pm1.g1) SELECT a.x, a.y,
pm1.g2.e1 from a left outer join pm1.g2 makenotdep on (rtrim(a.x) = pm1.g2.e1) order by
a.y"; //$NON-NLS-1$
+
+ HardcodedDataManager dataManager = new HardcodedDataManager() {
+ @Override
+ public TupleSource registerRequest(CommandContext context,
+ Command command,
+ String modelName,
+ String connectorBindingId, int nodeID, int limit)
+ throws TeiidComponentException {
+ final TupleSource ts = super.registerRequest(context, command, modelName, null,
0, 0);
+ return new TupleSource() {
+ int i = 0;
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ if ((i++ % 100)<3) {
+ throw BlockedException.INSTANCE;
+ }
+ return ts.nextTuple();
+ }
+
+ @Override
+ public void closeSource() {
+ ts.closeSource();
+ }
+ };
+ }
+ };
+ List<?>[] rows = new List[10];
+ for (int i = 0; i < rows.length; i++) {
+ rows[i] = Arrays.asList(String.valueOf(i));
+ }
+ dataManager.addData("SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 ORDER BY
c_0", rows);
+ rows = new List[100];
+ for (int i = 0; i < rows.length; i++) {
+ rows[i] = Arrays.asList(String.valueOf(i), i);
+ }
+ dataManager.addData("SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", rows);
+
+ dataManager.addData("WITH a (x, y) AS (SELECT 1, 2 FROM g1 AS g_0) SELECT g_0.x
AS c_0 FROM a AS g_0, a AS g_1 ORDER BY c_0", new List[0]);
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
RealMetadataFactory.example1Cached(), null, new
DefaultCapabilitiesFinder(TestOptimizer.getTypicalCapabilities()), new String[]
{"SELECT a.x, a.y FROM a", "SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 ORDER
BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING);
+ //check the full pushdown command
+
+ List<?>[] result = new List[100];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = Arrays.asList(String.valueOf(i), i, i < 10?String.valueOf(i):null);
+ }
+
+ helpProcess(plan, dataManager, result);
+ }
+
}