Search in sources :

Example 56 with ProcessorPlan

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

the class TestOptimizer method testSelectIntoWithDistinct.

@Test
public void testSelectIntoWithDistinct() throws Exception {
    // $NON-NLS-1$
    String sql = "select distinct e1 into #temp from pm1.g1";
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    ProcessorPlan plan = helpPlan(sql, metadata, new String[] { "SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING);
    // txn required, since the insert could be split
    assertTrue(plan.requiresTransaction(false));
    checkNodeTypes(plan, FULL_PUSHDOWN);
    checkNodeTypes(plan, new int[] { 1 }, new Class[] { ProjectIntoNode.class });
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 57 with ProcessorPlan

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

the class TestOptimizer method testSelectStarPhysical.

@Test
public void testSelectStarPhysical() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT * FROM pm1.g1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" });
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 58 with ProcessorPlan

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

the class TestOptimizer method testCopyInAcrossJoin.

// ############################# TESTS ON EXAMPLE 1 ############################
@Test
public void testCopyInAcrossJoin() throws Exception {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 IN ('a', 'b')", // $NON-NLS-1$
    example1(), new String[] { // $NON-NLS-1$
    "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    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
    0, // UnionAll
    0 });
}
Also used : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 59 with ProcessorPlan

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

the class TestOptimizer method testAggregateOverUnionPushdown.

@Test
public void testAggregateOverUnionPushdown() {
    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 COUNT(*) FROM (SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB) AS x", // $NON-NLS-1$
    RealMetadataFactory.exampleBQTCached(), null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB" }, 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 });
}
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 60 with ProcessorPlan

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

the class TestOptimizer method testPushGroupBy2.

@Test
public void testPushGroupBy2() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    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 e1, max(e2) as x FROM pm1.g1 GROUP BY e1", RealMetadataFactory.example1Cached(), null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT e1, MAX(e2) FROM pm1.g1 GROUP BY e1" }, 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)

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