use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testBadCollapseUnion.
// since this does not support convert, it should not be collapsed
@Test
public void testBadCollapseUnion() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// $NON-NLS-1$
String sql = "select convert(e2+1,string) from pm1.g1 union all select e1 from pm1.g2";
// $NON-NLS-1$ //$NON-NLS-2$
String[] expectedSql = new String[] { "SELECT e2 FROM pm1.g1", "SELECT e1 FROM pm1.g2" };
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, expectedSql, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // Join
0, // MergeJoin
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
1 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testCase6597.
@Test
public void testCase6597() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
caps.setCapabilitySupport(Capability.CRITERIA_NOT, false);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// Create query
// $NON-NLS-1$
String sql = "select IntKey from bqt1.smalla where stringkey not like '2%'";
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT stringkey, IntKey FROM bqt1.smalla" }, // $NON-NLS-1$
TestOptimizer.SHOULD_SUCCEED);
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
1, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testBetweenInCase.
/**
* Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
* query containing a <code>CASE</code> expression in which a
* <code>BETWEEN</code> comparison is used in the queries
* <code>SELECT</code> statement.
* <p>
* For example:
* <p>
* SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
*/
@Test
public void testBetweenInCase() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
helpPlan(// $NON-NLS-1$
"select case when e2 between 3 and 5 then e2 else -1 end from pm1.g1", RealMetadataFactory.example1Cached(), null, capFinder, // $NON-NLS-1$
new String[] { "SELECT CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END FROM pm1.g1" }, TestOptimizer.SHOULD_SUCCEED);
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method helpTestUnionPushdown.
public void helpTestUnionPushdown(boolean queryHasOrderBy, boolean hasUnionCapability, boolean hasUnionOrderByCapability) {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_UNION, hasUnionCapability);
caps.setCapabilitySupport((Capability.QUERY_ORDERBY), hasUnionOrderByCapability);
caps.setCapabilitySupport((Capability.QUERY_SET_ORDER_BY), hasUnionOrderByCapability);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
// $NON-NLS-1$
String sqlUnion = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB";
// $NON-NLS-1$
String sqlOrderBy = sqlUnion + " ORDER BY IntKey";
String sql = null;
if (queryHasOrderBy) {
sql = sqlOrderBy;
} else {
sql = sqlUnion;
}
String[] expectedSql = null;
if (hasUnionCapability) {
if (queryHasOrderBy && hasUnionOrderByCapability) {
expectedSql = new String[] { sqlOrderBy };
} else {
expectedSql = new String[] { sqlUnion };
}
} else {
// $NON-NLS-1$//$NON-NLS-2$
expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" };
}
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expectedSql, SHOULD_SUCCEED);
int accessCount = hasUnionCapability ? 1 : 2;
int projectCount = 0;
int sortCount = 0;
if (queryHasOrderBy && !(hasUnionCapability && hasUnionOrderByCapability)) {
sortCount = 1;
}
int unionCount = hasUnionCapability ? 0 : 1;
checkNodeTypes(plan, new int[] { // Access
accessCount, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
projectCount, // Select
0, // Sort
sortCount, // UnionAll
unionCount });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testCorrelatedSubqueryOverJoin.
/**
* previously the subqueries were being pushed too far and then not having the appropriate correlated references
*/
@Test
public void testCorrelatedSubqueryOverJoin() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
String sql = "select pm1.g1.e1 from pm1.g1, (select * from pm1.g2) y where (pm1.g1.e1 = y.e1) and exists (select e2 from pm1.g2 where e1 = y.e1) and exists (select e3 from pm1.g2 where e1 = y.e1)";
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (EXISTS (SELECT g_2.e2 FROM pm1.g2 AS g_2 WHERE g_2.e1 = g_1.e1)) AND (EXISTS (SELECT g_3.e3 FROM pm1.g2 AS g_3 WHERE g_3.e1 = g_1.e1))" }, // $NON-NLS-1$
ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
Aggregations