use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testPushAggregate3.
@Test
public void testPushAggregate3() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2", RealMetadataFactory.example1Cached(), null, capFinder, // $NON-NLS-1$
new String[] { "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2" }, SHOULD_SUCCEED);
checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testCase2507_2.
@Test
public void testCase2507_2() {
String sql = // $NON-NLS-1$
"SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " + // $NON-NLS-1$
"FROM BQT1.SmallA, BQT1.SmallB WHERE SmallA.IntKey = SmallB.IntKey) as X ORDER BY X.a";
String expected = // $NON-NLS-1$
"SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) AS EXPR " + // $NON-NLS-1$
"FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = BQT1.SmallB.IntKey ORDER BY EXPR";
// Plan query
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, 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.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
// $NON-NLS-1$
caps.setFunctionSupport("concat", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[] { expected }, TestOptimizer.SHOULD_SUCCEED);
TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testPushSelfJoin2.
@Test
public void testPushSelfJoin2() {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = getTypicalCapabilities();
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
// $NON-NLS-1$
capFinder.addCapabilities("pm1", caps);
// Add join capability to pm1
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT a.e1 AS x, concat(a.e2, b.e2) AS y FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", metadata, null, capFinder, // $NON-NLS-1$
new String[] { "SELECT a.e1, a.e2, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1" }, 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
0, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testDefect14510LookupFunction2.
/**
* defect 14510
*/
@Test
public void testDefect14510LookupFunction2() throws Exception {
FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
BasicSourceCapabilities caps = new BasicSourceCapabilities();
caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQT();
// $NON-NLS-1$
RealMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata);
// $NON-NLS-1$
RealMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata);
ProcessorPlan plan = helpPlan(// $NON-NLS-1$
"SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)", metadata, null, capFinder, // $NON-NLS-1$ //$NON-NLS-2$
new String[] { "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB" }, SHOULD_SUCCEED);
checkNodeTypes(plan, new int[] { // Access
2, // DependentAccess
0, // DependentSelect
0, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
1, // Null
0, // PlanExecution
0, // Project
2, // Select
1, // Sort
0, // UnionAll
0 });
}
use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.
the class TestOptimizer method testCase2125.
@Test
public void testCase2125() 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_NOT, true);
caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
// $NON-NLS-1$
caps.setFunctionSupport("convert", true);
// $NON-NLS-1$
capFinder.addCapabilities("BQT1", caps);
String sql = // $NON-NLS-1$
"SELECT OD.IntKEy, P.IntKEy, O.IntKey " + // $NON-NLS-1$
"FROM (bqt1.smalla AS OD INNER JOIN bqt1.smallb AS P ON OD.StringKey = P.StringKey) " + // $NON-NLS-1$
"INNER JOIN bqt1.mediuma AS O ON O.IntKey = OD.IntKey " + // $NON-NLS-1$
"WHERE (OD.IntNum > /*+ no_unnest */ (SELECT SUM(IntNum) FROM bqt1.smalla)) AND " + // $NON-NLS-1$
"(P.longnum > /*+ no_unnest */ (SELECT AVG(LongNum) FROM bqt1.smallb WHERE bqt1.smallb.datevalue = O.datevalue))";
ProcessorPlan plan = helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, // $NON-NLS-1$
new String[] { "SELECT g_1.LongNum, g_2.DateValue, g_0.IntKey, g_1.IntKey, g_2.IntKey FROM BQT1.SmallA AS g_0, BQT1.SmallB AS g_1, BQT1.MediumA AS g_2 WHERE (g_0.StringKey = g_1.StringKey) AND (g_2.IntKey = g_0.IntKey) AND (convert(g_0.IntNum, long) > /*+ NO_UNNEST */ (SELECT SUM(g_3.IntNum) FROM BQT1.SmallA AS g_3))" }, ComparisonMode.EXACT_COMMAND_STRING);
checkNodeTypes(plan, new int[] { // Access
1, // DependentAccess
0, // DependentSelect
1, // DependentProject
0, // DupRemove
0, // Grouping
0, // NestedLoopJoinStrategy
0, // MergeJoinStrategy
0, // Null
0, // PlanExecution
0, // Project
1, // Select
0, // Sort
0, // UnionAll
0 });
}
Aggregations