Search in sources :

Example 76 with ProcessorPlan

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

the class TestOptimizer method testPushAggregate5.

/**
 * Can't push aggs due to not being able to push COUNT in the HAVING clause.
 */
@Test
public void testPushAggregate5() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0", RealMetadataFactory.example1Cached(), null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT e2, 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 77 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan 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);
}
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 78 with ProcessorPlan

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

the class TestOptimizer method testCopyCriteriaWithTransitivePushdown3.

@Test
public void testCopyCriteriaWithTransitivePushdown3() throws TeiidComponentException, TeiidProcessingException {
    BasicSourceCapabilities caps = getTypicalCapabilities();
    caps.setFunctionSupport(SourceSystemFunctions.CONVERT, true);
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select pm1.g1.e1 from pm1.g1, pm1.g2, pm1.g3 where pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e1 = pm1.g3.e2 and pm1.g3.e2 = pm1.g2.e1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = convert(g_2.e2, string)) AND (convert(g_2.e2, string) = g_1.e1)" }, new DefaultCapabilitiesFinder(caps), // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    checkNodeTypes(plan, FULL_PUSHDOWN);
}
Also used : BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 79 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan 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);
}
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 80 with ProcessorPlan

use of org.teiid.query.processor.ProcessorPlan 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 });
}
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