Search in sources :

Example 56 with BasicSourceCapabilities

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

the class TestOptimizer method testCantPushCaseInSelectWithFunction.

@Test
public void testCantPushCaseInSelectWithFunction() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    caps.setCapabilitySupport(Capability.QUERY_CASE, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", metadata, null, capFinder, // $NON-NLS-1$
    new String[] { "SELECT e1, e2 FROM pm1.g1" }, 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)

Example 57 with BasicSourceCapabilities

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

the class TestOptimizer method testUseMergeJoin5_CostsNotKnown.

/**
 * Should use merge join, since costs are not known, neither access node is "strong"
 */
@Test
public void testUseMergeJoin5_CostsNotKnown() {
    // Create query
    // $NON-NLS-1$
    String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, // $NON-NLS-1$ //$NON-NLS-2$
    SHOULD_SUCCEED);
    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 : 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 58 with BasicSourceCapabilities

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

the class TestOptimizer method testCase2589w.

/**
 * Same as previous testCase2589v, but with full outer join.
 */
@Test
public void testCase2589w() {
    String sql = // $NON-NLS-1$
    "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + // $NON-NLS-1$
    "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey";
    String[] expected = new String[] { // $NON-NLS-1$
    "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", // $NON-NLS-1$
    "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" };
    // Plan query
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
    // $NON-NLS-1$
    caps.setFunctionSupport("concat", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, expected, SHOULD_SUCCEED);
    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 : 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 59 with BasicSourceCapabilities

use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities 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 60 with BasicSourceCapabilities

use of org.teiid.query.optimizer.capabilities.BasicSourceCapabilities 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)

Aggregations

BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)826 Test (org.junit.Test)780 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)525 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)357 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)277 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)210 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)163 List (java.util.List)135 CommandContext (org.teiid.query.util.CommandContext)104 Command (org.teiid.query.sql.lang.Command)73 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)53 ArrayList (java.util.ArrayList)34 BigInteger (java.math.BigInteger)33 Schema (org.teiid.metadata.Schema)18 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)16 Table (org.teiid.metadata.Table)15 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)12 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)12 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)11 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)10