Author: shawkins
Date: 2012-03-14 14:56:05 -0400 (Wed, 14 Mar 2012)
New Revision: 3940
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
Log:
TEIID-1972 fix for inappropriate staging and fixing a message
Modified:
branches/7.7.x/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties
===================================================================
---
branches/7.7.x/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2012-03-14
15:17:58 UTC (rev 3939)
+++
branches/7.7.x/connectors/translator-jdbc/src/main/resources/org/teiid/translator/jdbc/i18n.properties 2012-03-14
18:56:05 UTC (rev 3940)
@@ -28,6 +28,6 @@
JDBCQueryExecution.Error_executing_query__1 = ''{0}'' error executing
statement(s): {1}
SQLConversionVisitor.invalid_parameter=Invalid parameter {0}. Must be between 1 and
{1}.
SQLConversionVisitor.not_in_parameter=Invalid parameter {0}. Native query procedures
cannot use non IN parameters.
-OraleExecutionFactory.invalid_hint=Not using oracle execution payload {0} as hint, since
it apprears to contain more than just a single comment.
+OraleExecutionFactory.invalid_hint=Not using oracle execution payload {0} as hint, since
it appears to contain more than just a single comment.
ConnectionListener.failed_to_report_jdbc_connection_details=Failed to report the JDBC
driver and connection information
JDBCMetadataProcessor.not_unique=Teiid runtime names, which are case insensitive, for the
imported metadata are not unique. If not already set, use the setting
importer.useFullSchemaName to create Teiid names that include the source schema.
\ No newline at end of file
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
---
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2012-03-14
15:17:58 UTC (rev 3939)
+++
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2012-03-14
18:56:05 UTC (rev 3940)
@@ -22,19 +22,7 @@
package org.teiid.query.optimizer.relational.rules;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
@@ -69,16 +57,7 @@
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.SetQuery.Operation;
-import org.teiid.query.sql.symbol.AggregateSymbol;
-import org.teiid.query.sql.symbol.AliasSymbol;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.ExpressionSymbol;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.*;
import org.teiid.query.sql.symbol.AggregateSymbol.Type;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
@@ -795,12 +774,12 @@
return result;
}
for (T aggregateSymbol : expressions) {
- if (aggs && ((AggregateSymbol)aggregateSymbol).getExpression() == null)
{
- return null; //count(*) is not yet handled. a general approach would be
count(*) => count(r.col) * count(l.col), but the logic here assumes a simpler initial
mapping
+ if (aggs) {
+ AggregateSymbol as = (AggregateSymbol)aggregateSymbol;
+ if ((!as.canStage() && as.isCardinalityDependent()) ||
(as.getAggregateFunction() == Type.COUNT && as.getExpression() == null)) {
+ return null; //count(*) is not yet handled. a general approach would be
count(*) => count(r.col) * count(l.col), but the logic here assumes a simpler initial
mapping
+ }
}
- if (aggs && !((AggregateSymbol)aggregateSymbol).canStage()) {
- continue;
- }
Set<GroupSymbol> groups =
GroupsUsedByElementsVisitor.getGroups(aggregateSymbol);
if (groups.isEmpty()) {
continue;
Modified:
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
===================================================================
---
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2012-03-14
15:17:58 UTC (rev 3939)
+++
branches/7.7.x/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2012-03-14
18:56:05 UTC (rev 3940)
@@ -620,6 +620,32 @@
});
}
+ @Test public void testCountXMLAgg() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select count(X.e1),
xmlagg(xmlelement(name e1, x.e1) order by x.e2) FROM pm1.g1 as X, pm2.g2 as Y group by
X.e2", RealMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT 1 FROM pm2.g2 AS g_0", "SELECT g_0.e2,
g_0.e1 FROM pm1.g1 AS g_0"}, true); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
@Test public void testBusObjQuestion1() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getTypicalCapabilities();
Show replies by date