Search in sources :

Example 61 with ProcessorPlan

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

the class TestOptimizer method testAggregateWithoutGroupBy.

@Test
public void testAggregateWithoutGroupBy() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select count(e2) from pm1.g1", // $NON-NLS-1$
    example1(), // $NON-NLS-1$
    new String[] { "SELECT e2 FROM pm1.g1" });
    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 : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 62 with ProcessorPlan

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

the class TestOptimizer method testPushDistinctVirtual5.

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

Example 63 with ProcessorPlan

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

the class TestOptimizer method testHavingAndGroupBy.

@Test
public void testHavingAndGroupBy() {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select e1, count(e2) from pm1.g1 group by e1 having count(e2) > 0 and sum(e2) > 0", // $NON-NLS-1$
    example1(), // $NON-NLS-1$
    new String[] { "SELECT e1, e2 FROM pm1.g1" });
    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 : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 64 with ProcessorPlan

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

the class TestOptimizer method testLookupFunction2.

/**
 * case 5213 - note here that the lookup cannot be pushed down since it is dependent upon an element symbol
 */
@Test
public void testLookupFunction2() throws Exception {
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e2) IS NULL", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e2, g_0.e1 FROM pm1.g2 AS g_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    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 : ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 65 with ProcessorPlan

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

the class TestOptimizer method testPushFunctionInJoin1.

@Test
public void testPushFunctionInJoin1() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
    caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
    // $NON-NLS-1$
    caps.setFunctionSupport("convert", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // Add join capability to pm1
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND upper(pm1.g1.e1) = 'X'", metadata, null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X')" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
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)

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