Author: shawkins
Date: 2011-05-31 21:01:56 -0400 (Tue, 31 May 2011)
New Revision: 3208
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
Log:
TEIID-1617 fix for inappropriate subquery rewrite
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-05-31
18:52:23 UTC (rev 3207)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-06-01
01:01:56 UTC (rev 3208)
@@ -704,16 +704,6 @@
if (!rmc.planQuery(groups, requiresDistinct, plannedResult)) {
continue;
}
- if (requiresDistinct) {
- //check for key preservation
- HashSet<GroupSymbol> keyPreservingGroups = new HashSet<GroupSymbol>();
- ResolverUtil.findKeyPreserved(query, keyPreservingGroups, metadata);
- if (NewCalculateCostUtil.usesKey(plannedResult.leftExpressions, keyPreservingGroups,
metadata, true) && plannedResult.madeDistinct) {
- //if key perserved then the semi-join will remain in-tact without make the other
query distinct
- plannedResult.madeDistinct = false;
- plannedResult.query.getSelect().setDistinct(false);
- }
- }
crits.remove();
GroupSymbol viewName = RulePlaceAccess.recontextSymbol(new GroupSymbol("X"),
names); //$NON-NLS-1$
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-05-31
18:52:23 UTC (rev 3207)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-06-01
01:01:56 UTC (rev 3208)
@@ -783,9 +783,13 @@
}
@Test public void testSubqueryRewriteToJoin2() throws Exception {
- TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where
pm3.g1.e1 in /*+ mj */ (select pm1.g1.e1 || 1 FROM pm1.g1)", "SELECT e1 FROM
pm3.g1, (SELECT concat(pm1.g1.e1, '1') AS EXPR FROM pm1.g1) AS X__1 WHERE
pm3.g1.e1 = X__1.EXPR", RealMetadataFactory.example4());
+ TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where
pm3.g1.e1 in /*+ mj */ (select distinct pm1.g1.e1 || 1 FROM pm1.g1)", "SELECT e1
FROM pm3.g1, (SELECT DISTINCT concat(pm1.g1.e1, '1') AS EXPR FROM pm1.g1) AS X__1
WHERE pm3.g1.e1 = X__1.EXPR", RealMetadataFactory.example4());
}
-
+
+ @Test public void testSubqueryRewriteToJoin2a() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where
pm3.g1.e1 in /*+ mj */ (select pm1.g1.e1 || 1 FROM pm1.g1)", "SELECT e1 FROM
pm3.g1, (SELECT DISTINCT concat(pm1.g1.e1, '1') AS EXPR FROM pm1.g1) AS X__1 WHERE
pm3.g1.e1 = X__1.EXPR", RealMetadataFactory.example4());
+ }
+
/**
* Even though this situation is essentially the same as above, we don't yet
handle it
*/
Show replies by date