Author: shawkins
Date: 2010-06-22 16:53:33 -0400 (Tue, 22 Jun 2010)
New Revision: 2281
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
Log:
TEIID-1107 adding the ability to raise criteria if it's been pushed too far.
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-06-22
19:56:42 UTC (rev 2280)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-06-22
20:53:33 UTC (rev 2281)
@@ -179,7 +179,7 @@
while (selectRoot.getParent() != null &&
selectRoot.getParent().getType() == NodeConstants.Types.SELECT) {
selectRoot = selectRoot.getParent();
}
- if (selectRoot.getParent() == null || selectRoot.getParent().getType() ==
NodeConstants.Types.PROJECT) {
+ if (selectRoot.getParent() == null || (selectRoot.getParent().getType() &
(NodeConstants.Types.PROJECT|NodeConstants.Types.GROUP)) ==
selectRoot.getParent().getType()) {
return null;
}
PlanNode grandParent = selectRoot.getParent();
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2010-06-22
19:56:42 UTC (rev 2280)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2010-06-22
20:53:33 UTC (rev 2281)
@@ -37,7 +37,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.translator.SourceSystemFunctions;
-
+@SuppressWarnings("nls")
public class TestAggregatePushdown {
public static BasicSourceCapabilities getAggregateCapabilities() {
@@ -867,5 +867,37 @@
1 // UnionAll
});
}
+
+ /**
+ * Ensures that we do not raise criteria over a group by
+ * TODO: check if the criteria only depends on grouping columns
+ */
+ @Test public void testForCase836073GroupBy() throws Exception {
+ String sql = "select count(*) from bqt1.smallb where
formatdate(bqt1.smallb.DateValue,'yyyyMM') = '200309'";
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, getAggregatesFinder(),
+ new String[] {"SELECT g_0.DateValue FROM bqt1.smallb AS g_0"},
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
}
Show replies by date