Author: shawkins
Date: 2009-08-28 18:21:19 -0400 (Fri, 28 Aug 2009)
New Revision: 1289
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
Log:
TEIID-810 the context is needed for reference evaluation at limit nodes
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java 2009-08-28
20:43:58 UTC (rev 1288)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java 2009-08-28
22:21:19 UTC (rev 1289)
@@ -22,6 +22,7 @@
package com.metamatrix.query.processor.relational;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -109,14 +110,13 @@
super.open();
limit = -1;
if (limitExpr != null) {
- Integer limitVal = (Integer)Evaluator.evaluate(limitExpr);
+ Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(),
getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList());
limit = limitVal.intValue();
}
if (offsetExpr != null) {
- Integer offsetVal = (Integer)Evaluator.evaluate(offsetExpr);
+ Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(),
getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList());
offset = offsetVal.intValue();
- Assertion.assertTrue(offset >= 0);
} else {
offset = 0;
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-08-28
20:43:58 UTC (rev 1288)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-08-28
22:21:19 UTC (rev 1289)
@@ -413,6 +413,19 @@
helpTestProcessing(preparedSql, values, expected, dataManager,
FakeMetadataFactory.example1Cached(), false, false);
}
+ @Test public void testLimitParam() throws Exception {
+ String preparedSql = "select e1 from pm1.g1 order by e1 desc limit ?";
//$NON-NLS-1$
+
+ List<?> values = Arrays.asList(1);
+ List[] expected = new List[] {
+ Arrays.asList("c"), //$NON-NLS-1$s
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ helpTestProcessing(preparedSql, values, expected, dataManager,
FakeMetadataFactory.example1Cached(), false, false);
+ }
+
@Test public void testXQueryParam() throws Exception {
String preparedSql = "exec m.xproc3(?)"; //$NON-NLS-1$
Show replies by date