use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestJoinOptimization method testOuterToInnerJoinConversion4.
/**
* non-dependent criteria on each side of a full outer creates an inner join
*/
@Test
public void testOuterToInnerJoinConversion4() {
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = bqt1.smallb.intnum";
// $NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = bqt1.smallb.intnum)" });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestJoinOptimization method testOuterToInnerJoinConversion1.
// same as above, but with a right outer join
@Test
public void testOuterToInnerJoinConversion1() {
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey from bqt1.smalla right outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1";
// $NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT bqt1.smalla.intkey FROM bqt1.smallb, bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = 1)" });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestJoinOptimization method testOuterToInnerJoinConversion3.
@Test
public void testOuterToInnerJoinConversion3() {
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1";
// $NON-NLS-1$
TestOptimizer.helpPlan(sql, metadata, new String[] { "SELECT bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smalla.intnum = 1" });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestJoinOptimization method testOuterJoinPushNonJoinCriteria_Case5547.
@Test
public void testOuterJoinPushNonJoinCriteria_Case5547() {
// $NON-NLS-1$
String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (1=1)";
// $NON-NLS-1$
String BQT1 = "BQT1";
// $NON-NLS-1$
String BQT2 = "BQT2";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
// === Must set the ORDER BY prop on the capabilities object to TRUE
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
capFinder.addCapabilities(BQT1, caps);
capFinder.addCapabilities(BQT2, caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// Plan query
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT bqt1.smalla.intkey FROM bqt1.smalla", "SELECT 1 FROM bqt2.smalla" }, // $NON-NLS-1$ //$NON-NLS-2$
true);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
1, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.metadata.QueryMetadataInterface in project teiid by teiid.
the class TestJoinOptimization method testCriteriaPushedWithUnionJoin1.
/**
* union joins allow RuleRemoveVirtual to still take effect
*/
@Test
public void testCriteriaPushedWithUnionJoin1() throws Exception {
// $NON-NLS-1$
String sql = "select vm1.g1.e1 from vm1.g1 union join vm1.g2 where g2.e1 = 1";
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[] { // $NON-NLS-1$
"SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = '1')" }, ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations