Author: shawkins
Date: 2011-04-20 16:35:21 -0400 (Wed, 20 Apr 2011)
New Revision: 3109
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
Log:
TEIID-1562 fix for assertion errors due to view removal
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-04-20
20:03:25 UTC (rev 3108)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2011-04-20
20:35:21 UTC (rev 3109)
@@ -108,7 +108,11 @@
if(endNode == null) {
return;
}
- // Top of a frame - fix symbol mappings on endNode
+ correctSymbolMap(symbolMap, endNode);
+ }
+
+ static void correctSymbolMap(Map symbolMap, PlanNode endNode) {
+ // Top of a frame - fix symbol mappings on endNode
SymbolMap parentSymbolMap = (SymbolMap)
endNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
if(parentSymbolMap == null) {
return;
@@ -117,8 +121,7 @@
for (Map.Entry<ElementSymbol, Expression> entry :
parentSymbolMap.asUpdatableMap().entrySet()) {
entry.setValue(convertExpression(entry.getValue(), symbolMap));
}
-
- }
+ }
static boolean canConvertAccessPatterns(PlanNode sourceNode) {
List accessPatterns =
(List)sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-04-20
20:03:25 UTC (rev 3108)
+++
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2011-04-20
20:35:21 UTC (rev 3109)
@@ -291,8 +291,13 @@
sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
}
- prepareFrame(frame);
+ PlanNode parentSource = NodeEditor.findParent(parentProject,
NodeConstants.Types.SOURCE);
+
+ if (parentSource != null) {
+
FrameUtil.correctSymbolMap(((SymbolMap)frame.getProperty(NodeConstants.Info.SYMBOL_MAP)).asMap(),
parentSource);
+ }
+
//remove the parent project and the source node
NodeEditor.removeChildNode(parentProject, frame);
if (parentProject.getParent() == null) {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-04-20
20:03:25 UTC (rev 3108)
+++
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2011-04-20
20:35:21 UTC (rev 3109)
@@ -37,7 +37,7 @@
import org.teiid.query.unittest.FakeMetadataFacade;
import org.teiid.query.unittest.FakeMetadataFactory;
-
+@SuppressWarnings("nls")
public class TestRuleMergeVirtual {
@Test public void testSimpleMergeGroupBy() {
@@ -184,6 +184,20 @@
});
}
+ //see TEIID-1562
+ @Test public void testSimpleMergeUnderUnionWithJoin() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan("select * from (SELECT x.x, x.e2 FROM (select
'1' as x, pm1.g1.e2 from pm1.g1, pm1.g2 where pm1.g1.e1 = pm1.g2.e1 group by
pm1.g1.e2, pm1.g1.e3 || '1') x union all select e1, 1 from pm1.g2) as y where x =
'1'", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null,
capFinder,
+ new String[] {
+ "SELECT pm1.g2.e1 FROM pm1.g2",
"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3 FROM pm1.g1"},
TestOptimizer.SHOULD_SUCCEED);
+ }
+
@Test public void testSimpleMergeUnion3() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
Show replies by date