Search in sources :

Example 66 with BasicSourceCapabilities

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

the class TestOptimizer method testUnnamedAggInView.

@Test
public void testUnnamedAggInView() throws Exception {
    MetadataStore metadataStore = new MetadataStore();
    // $NON-NLS-1$
    Schema bqt1 = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore);
    // $NON-NLS-1$
    Schema vqt = RealMetadataFactory.createVirtualModel("VQT", metadataStore);
    // $NON-NLS-1$
    Table bqt1SmallA = RealMetadataFactory.createPhysicalGroup("SmallA", bqt1);
    RealMetadataFactory.createElement("col", bqt1SmallA, DataTypeManager.DefaultDataTypes.STRING);
    Table agg3 = RealMetadataFactory.createVirtualGroup("Agg3", vqt, new QueryNode("select count(*) from smalla"));
    RealMetadataFactory.createElement("count", agg3, DataTypeManager.DefaultDataTypes.INTEGER);
    TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "x");
    BasicSourceCapabilities bac = getTypicalCapabilities();
    bac.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
    bac.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
    bac.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
    helpPlan("select count(*) from agg3", metadata, new String[] {}, new DefaultCapabilitiesFinder(bac), ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Table(org.teiid.metadata.Table) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 67 with BasicSourceCapabilities

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

the class TestOptimizer method testCase3778.

/*
     * Set criteria was not getting pushed down correctly when there was a self-join 
     * of a virtual table containing a join in it's transformation.  All virtual 
     * models use the same physical model pm1.
     */
@Test
public void testCase3778() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    BasicSourceCapabilities caps = getTypicalCapabilities();
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
    caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = helpPlan(// $NON-NLS-1$
    "select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in /*+ no_unnest */ (select e2 from vm1.g1)", metadata, null, capFinder, new String[] { "SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN /*+ NO_UNNEST */ (SELECT g_4.e2 FROM pm1.g1 AS g_4))" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    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 68 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testPushDownOverUnionMixed.

@Test
public void testPushDownOverUnionMixed() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities());
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select max(e2), count(*) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm2.g2) z", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT g_0.e2 FROM pm2.g2 AS g_0", "SELECT MAX(g_0.e2), COUNT(*) FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // 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
    1 });
}
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 69 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testGroupByConstant.

@Test
public void testGroupByConstant() throws Exception {
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
    String sql = "SELECT x from (select 'aaa' as x FROM pm1.g1) AS g_0 GROUP BY x";
    // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), new String[] { "SELECT v_0.c_0 FROM (SELECT 'aaa' AS c_0 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0" }, new DefaultCapabilitiesFinder(caps), ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 70 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testAvgAggregate.

/**
 * Average requires the creation of staged sum and count aggregates
 */
@Test
public void testAvgAggregate() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm2", caps);
    // $NON-NLS-1$
    String sql = "SELECT avg(y.e2) from pm1.g1 x, pm2.g1 y where x.e4 = y.e4 group by x.e2, y.e1";
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e4, g_0.e2 FROM pm1.g1 AS g_0", "SELECT g_0.e4, g_0.e1, SUM(g_0.e2), COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e4, g_0.e1" }, // $NON-NLS-1$ //$NON-NLS-2$
    TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // 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) 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