Search in sources :

Example 76 with FakeCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.

the class TestAggregatePushdown method testBusObjQuestion3.

@Test
public void testBusObjQuestion3() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("db2model", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("oraclemodel", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("msmodel", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBusObj();
    // $NON-NLS-1$
    String sql = "select sum(c0), sum(b0), c1, b2 FROM db2Table, OraTable where c2=b2 group by c1, b2";
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT g_0.c2, g_0.c1, g_0.c0 FROM db2model.DB2TABLE AS g_0", // $NON-NLS-1$
    "SELECT g_0.b2 AS c_0, g_0.b0 AS c_1 FROM oraclemodel.OraTable AS g_0 ORDER BY c_0" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    2, // NestedLoopJoinStrategy
    0, // MergeJoinStrategy
    1, // Null
    0, // PlanExecution
    0, // Project
    1, // Select
    0, // Sort
    0, // UnionAll
    0 });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 77 with FakeCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.

the class TestAggregatePushdown method testNoHavingAggregate.

@Test
public void testNoHavingAggregate() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
    "select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT COUNT(g_0.IntKey), g_0.StringKey, MAX(g_0.IntKey) FROM BQT1.SmallA AS g_0 GROUP BY g_0.StringKey" }, 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
    1, // Sort
    0, // UnionAll
    0 });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 78 with FakeCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.

the class TestAggregatePushdown method testPushDownOverUnion.

@Test
public void testPushDownOverUnion() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select e1, max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) y group by e1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT g_0.e1, MAX(g_0.e2) FROM pm1.g1 AS g_0 GROUP BY g_0.e1", "SELECT g_0.e1, MAX(g_0.e2) FROM pm1.g2 AS g_0 GROUP BY g_0.e1" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // 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
    1 });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 79 with FakeCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.

the class TestAggregatePushdown method testPushDownOverUnion1.

@Test
public void testPushDownOverUnion1() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) z", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT MAX(g_0.e2) FROM pm1.g2 AS g_0", "SELECT MAX(g_0.e2) FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // 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
    1 });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 80 with FakeCapabilitiesFinder

use of org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder in project teiid by teiid.

the class TestBatchedUpdatePlanner method testPlannerSomeCommandsBatched.

public void testPlannerSomeCommandsBatched() throws Exception {
    String[] sql = { // $NON-NLS-1$
    "INSERT INTO pm1.g1 (e1, e2, e3, e4) values ('string1', 1, {b'true'}, 1.0)", // $NON-NLS-1$
    "INSERT INTO pm1.g2 (e1, e2, e3, e4) values ('string1', 1, {b'true'}, 1.0)", // $NON-NLS-1$
    "DELETE FROM pm2.g1 WHERE e2 > 5000", // $NON-NLS-1$
    "INSERT INTO pm2.g1 (e1, e2, e3, e4) values ('5000', 5000, {b'true'}, 5000.0)", // $NON-NLS-1$
    "UPDATE pm2.g1 set e2 = -1 WHERE e2 = 4999", // $NON-NLS-1$
    "DELETE FROM pm1.g2 WHERE e2 = 50" };
    FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
    // $NON-NLS-1$
    finder.addCapabilities("pm1", new FakeCapabilities(false));
    // $NON-NLS-1$
    finder.addCapabilities("pm2", new FakeCapabilities(true));
    boolean[] expectedBatching = { false, false, true, false };
    helpTestPlanner(sql, expectedBatching, finder);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)

Aggregations

FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)544 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)513 Test (org.junit.Test)497 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)288 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)182 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)91 Command (org.teiid.query.sql.lang.Command)64 List (java.util.List)63 BigInteger (java.math.BigInteger)32 ArrayList (java.util.ArrayList)28 CommandContext (org.teiid.query.util.CommandContext)27 Schema (org.teiid.metadata.Schema)19 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)13 ColumnSet (org.teiid.metadata.ColumnSet)9 BigDecimal (java.math.BigDecimal)7 LinkedList (java.util.LinkedList)7 Column (org.teiid.metadata.Column)7 FunctionTree (org.teiid.query.function.FunctionTree)7 FakeFunctionMetadataSource (org.teiid.query.optimizer.FakeFunctionMetadataSource)6 FakeDataManager (org.teiid.query.processor.FakeDataManager)6