Author: shawkins
Date: 2011-06-10 12:28:08 -0400 (Fri, 10 Jun 2011)
New Revision: 3241
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
Log:
TEIID-1630 correcting final project minimization
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2011-06-09
19:23:59 UTC (rev 3240)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2011-06-10
16:28:08 UTC (rev 3241)
@@ -45,6 +45,7 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.rewriter.QueryRewriter;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.symbol.Constant;
@@ -204,6 +205,14 @@
}
if (!shouldProject) {
this.projection = new Object[0];
+ } else if (query.getOrderBy() != null) {
+ for (OrderByItem item : query.getOrderBy().getOrderByItems()) {
+ Integer index = uniqueSymbols.get(SymbolMap.getExpression(item.getSymbol()));
+ if (index != null) {
+ item.setExpressionPosition(index);
+ item.setSymbol((SingleElementSymbol) select.getSymbols().get(index));
+ }
+ }
}
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-06-09
19:23:59 UTC (rev 3240)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-06-10
16:28:08 UTC (rev 3241)
@@ -7512,7 +7512,6 @@
helpProcess(plan, dataManager, expected);
}
-
@Test public void testDupSelect() throws Exception {
String sql = "select e1, e1 from pm1.g1";
@@ -7537,5 +7536,18 @@
helpProcess(plan, dataManager, new List[] {Arrays.asList(1, 2)});
}
+ @Test public void testDupSelectWithOrderBy() throws Exception {
+ String sql = "select e1 as a, e1 as b from pm1.g1 order by b";
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ //note that the command is referencing c_0
+ dataManager.addData("SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY
c_0", new List[] {Arrays.asList(1)});
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached(),
TestOptimizer.getGenericFinder());
+
+ helpProcess(plan, dataManager, new List[] {Arrays.asList(1, 1)});
+ }
+
private static final boolean DEBUG = false;
}