use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testPushdownLiteralInSelectUnderAggregate3.
@Test
public void testPushdownLiteralInSelectUnderAggregate3() {
// $NON-NLS-1$
String sql = "SELECT code, SUM(ID) FROM (SELECT IntKey AS ID, '' AS Code FROM BQT1.SmallA union all select intkey, stringkey from bqt1.smallb b) AS x group by code";
// Plan query
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_SELECT_EXPRESSION, true);
caps.setCapabilitySupport(Capability.QUERY_UNION, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, // $NON-NLS-1$
new String[] { "SELECT '' AS Code, IntKey AS ID FROM BQT1.SmallA UNION ALL SELECT stringkey, intkey FROM bqt1.smallb AS b" }, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testUnionPushdownWithSelectNoFrom.
@Test
public void testUnionPushdownWithSelectNoFrom() {
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, true);
caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT 1 UNION ALL SELECT 2", // $NON-NLS-1$
RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] {}, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
0, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
2, // Select
0, // Sort
0, // UnionAll
1 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testOrderByDuplicates.
/**
* A final rewrite will ensure the correct order by
*/
@Test
public void testOrderByDuplicates() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, 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);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
// $NON-NLS-1$
String sql = "SELECT intkey, x FROM (select intkey, intkey x from bqt1.smalla) z ORDER BY x, intkey";
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 ORDER BY g_0.IntKey" }, ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testFunctionOfAggregateCantPush1.
@Test
public void testFunctionOfAggregateCantPush1() {
// $NON-NLS-1$
String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey";
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, // $NON-NLS-1$
new String[] { "SELECT IntKey FROM BQT1.SmallA" }, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
1, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method helpTestCase2589NonPushdown.
private void helpTestCase2589NonPushdown(String sql, String[] expected) {
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
// $NON-NLS-1$
caps.setFunctionSupport("concat", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expected, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // Join
0, // MergeJoin
1, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations