Search in sources :

Example 41 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan in project teiid by teiid.

the class TestOptimizer method testDontPushOrderByWithJoin.

/**
 * Tests an order by is not pushed to source due to join
 */
@Test
public void testDontPushOrderByWithJoin() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 INNER JOIN pm2.g2 ON pm3.g1.e1 = pm2.g2.e1 ORDER BY pm3.g1.e2", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), new String[] { // $NON-NLS-1$
    "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e1", // $NON-NLS-1$
    "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1" });
    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
    1, // Select
    0, // Sort
    1, // UnionAll
    0 });
}
Also used : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 42 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan in project teiid by teiid.

the class TestOptimizer method testUnionPushdownWithInternalOrderBy.

@Test
public void testUnionPushdownWithInternalOrderBy() {
    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_ORDERBY, true);
    caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
    // $NON-NLS-1$
    caps.setFunctionSupport("+", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "(SELECT IntKey FROM BQT1.SmallA ORDER BY IntKey) UNION ALL SELECT IntKey FROM BQT1.SmallB", // $NON-NLS-1$
    RealMetadataFactory.exampleBQTCached(), null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
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 43 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan in project teiid by teiid.

the class TestOptimizer method testPushAggregate7.

/**
 * Can't push aggs due to not being able to push function inside having
 */
@Test
public void testPushAggregate7() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT COUNT(*) FROM pm1.g1 GROUP BY e1 HAVING length(e1) > 0", RealMetadataFactory.example1Cached(), null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT e1 FROM pm1.g1" }, 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
    1, // Sort
    0, // UnionAll
    0 });
}
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 44 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan in project teiid by teiid.

the class TestOptimizer method testSubquery2.

@Test
public void testSubquery2() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "Select e1, a from (select e1 FROM pm1.g1) AS x, (select e1 as a FROM pm1.g2) AS y WHERE x.e1=y.a", // $NON-NLS-1$
    example1(), // $NON-NLS-1$
    new String[] { "SELECT g_0.e1, g_1.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1" });
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 45 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan in project teiid by teiid.

the class TestOptimizer method testCopyCriteriaWithTransitivePushdown.

@Test
public void testCopyCriteriaWithTransitivePushdown() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2, pm2.g3 where pm2.g1.e1 = pm2.g2.e1 and pm2.g2.e1 = pm2.g3.e1", // $NON-NLS-1$
    example1(), // $NON-NLS-1$
    new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1, pm2.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_1.e1 = g_2.e1)" });
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Aggregations

ProcessorPlan (org.teiid.query.processor.ProcessorPlan)814 Test (org.junit.Test)764 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)357 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)290 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)177 List (java.util.List)112 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)108 ArrayList (java.util.ArrayList)99 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)97 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)88 FakeDataManager (org.teiid.query.processor.FakeDataManager)86 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)33 TempMetadataAdapter (org.teiid.query.metadata.TempMetadataAdapter)32 CommandContext (org.teiid.query.util.CommandContext)26 Ignore (org.junit.Ignore)21 Command (org.teiid.query.sql.lang.Command)19 TeiidProcessingException (org.teiid.core.TeiidProcessingException)9 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)9 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)8 CreateProcedureCommand (org.teiid.query.sql.proc.CreateProcedureCommand)8