Author: shawkins
Date: 2011-04-07 07:39:30 -0400 (Thu, 07 Apr 2011)
New Revision: 3074
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1549 fixing unrelated aggregate order by
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2011-04-06
20:55:56 UTC (rev 3073)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2011-04-07
11:39:30 UTC (rev 3074)
@@ -498,6 +498,10 @@
if(aggExpr != null) {
AggregateSymbolCollectorVisitor.getAggregates(aggExpr,
requiredSymbols, requiredSymbols);
}
+ OrderBy orderBy = agg.getOrderBy();
+ if(orderBy != null) {
+ AggregateSymbolCollectorVisitor.getAggregates(orderBy,
requiredSymbols, requiredSymbols);
+ }
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-04-06
20:55:56 UTC (rev 3073)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-04-07
11:39:30 UTC (rev 3074)
@@ -270,6 +270,33 @@
helpProcess(plan, hdm, expected);
}
+ @Test public void testTextAggOrderByUnrelated() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, false);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select convert(to_chars(textagg(for pm1.g1.e1
header order by e2), 'UTF-8'), string) as x from pm1.g1", metadata, null,
capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" },
ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ HardcodedDataManager hdm = new HardcodedDataManager();
+ hdm.addData("SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", new List[]
{Arrays.asList("z", 2), Arrays.asList("b", 1)});
+ hdm.setBlockOnce(true);
+
+ String nl = System.getProperty("line.separator");
+ ArrayList list = new ArrayList();
+
list.add("\"e1\""+nl+"\"b\""+nl+"\"z\""+nl);
+ List[] expected = new List[] {
+ list,
+ };
+
+ helpProcess(plan, hdm, expected);
+ }
+
@Test(expected=TeiidProcessingException.class) public void testTextTableInvalidData()
throws Exception {
String sql = "select count(*) from texttable(? COLUMNS PARTNAME string)
x"; //$NON-NLS-1$
Show replies by date