Author: shawkins
Date: 2011-08-11 11:59:42 -0400 (Thu, 11 Aug 2011)
New Revision: 3376
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
Log:
TEIID-1706 fix to join planning with nested tables
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2011-08-11
11:36:26 UTC (rev 3375)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2011-08-11
15:59:42 UTC (rev 3376)
@@ -466,7 +466,9 @@
}
JoinType jt = (JoinType)root.getProperty(NodeConstants.Info.JOIN_TYPE);
- boolean treatJoinAsSource = jt.isOuter() ||
root.getProperty(NodeConstants.Info.ACCESS_PATTERNS) != null ||
root.hasProperty(NodeConstants.Info.MAKE_DEP) ||
root.hasProperty(NodeConstants.Info.MAKE_IND);
+ boolean treatJoinAsSource = jt.isOuter() ||
root.getProperty(NodeConstants.Info.ACCESS_PATTERNS) != null
+ || root.hasProperty(NodeConstants.Info.MAKE_DEP) ||
root.hasProperty(NodeConstants.Info.MAKE_IND)
+ || !root.getExportedCorrelatedReferences().isEmpty();
if (treatJoinAsSource) {
currentRegion.addJoinSourceNode(root);
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-08-11
11:36:26 UTC (rev 3375)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2011-08-11
15:59:42 UTC (rev 3376)
@@ -22,6 +22,7 @@
package org.teiid.query.processor;
+import static org.junit.Assert.*;
import static org.teiid.query.optimizer.TestOptimizer.*;
import static org.teiid.query.processor.TestProcessor.*;
@@ -43,6 +44,9 @@
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.NestedTableJoinStrategy;
+import org.teiid.query.processor.relational.RelationalPlan;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings({"unchecked", "nls"})
@@ -243,8 +247,26 @@
};
process(sql, expected);
- }
+ }
+ @Test public void testTextTableJoin() throws Exception {
+ String sql = "select z.* from (select x.* from (select * from pm1.g1 where e1 =
'c') y, texttable(e1 || '\n' || e2 || '\n' || e3 COLUMNS x string)
x) as z, " +
+ "(select x.* from (select * from pm1.g1 where e1 = 'c') y, texttable(e1
|| '\n' || e2 || '\n' || e3 COLUMNS x string) x) as z1 where z.x =
z1.x";
+
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ Arrays.asList("1"),
+ Arrays.asList("true"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ RelationalPlan plan = (RelationalPlan)helpGetPlan(helpParse(sql),
RealMetadataFactory.example1Cached());
+ JoinNode join = (JoinNode) plan.getRootNode().getChildren()[0];
+ assertTrue(!(join.getJoinStrategy() instanceof NestedTableJoinStrategy));
+ helpProcess(plan, createCommandContext(), dataManager, expected);
+ }
+
public static void process(String sql, List[] expectedResults) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);