Search in sources :

Example 86 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testCountXMLAgg.

@Test
public void testCountXMLAgg() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm2", caps);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select count(X.e1), xmlagg(xmlelement(name e1, x.e1) order by x.e2) FROM pm1.g1 as X, pm2.g2 as Y group by X.e2", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT 1 FROM pm2.g2 AS g_0", "SELECT g_0.e2, g_0.e1 FROM pm1.g1 AS g_0" }, // $NON-NLS-1$
    true);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    1, // 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 87 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testCase6327.

@Test
public void testCase6327() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    // $NON-NLS-1$
    caps.setFunctionSupport("convert", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT2", caps);
    // $NON-NLS-1$
    String sql = "SELECT a12.intkey AS REGION_NBR, SUM(a11.intnum) AS WJXBFS1 FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey WHERE a11.stringkey = 0 GROUP BY a12.intkey";
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT SUM(g_0.IntNum) FROM BQT1.SmallA AS g_0 WHERE g_0.StringKey = '0'", "SELECT g_0.IntKey FROM BQT2.SmallA AS g_0 WHERE g_0.StringKey = '0'" }, // $NON-NLS-1$ //$NON-NLS-2$
    TestOptimizer.SHOULD_SUCCEED);
    TestOptimizer.checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    1, // NestedLoopJoinStrategy
    1, // 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 88 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testBusObjQuestion3.

@Test
public void testBusObjQuestion3() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
    caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("db2model", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("oraclemodel", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("msmodel", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBusObj();
    // $NON-NLS-1$
    String sql = "select sum(c0), sum(b0), c1, b2 FROM db2Table, OraTable where c2=b2 group by c1, b2";
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT g_0.c2, g_0.c1, g_0.c0 FROM db2model.DB2TABLE AS g_0", // $NON-NLS-1$
    "SELECT g_0.b2 AS c_0, g_0.b0 AS c_1 FROM oraclemodel.OraTable AS g_0 ORDER BY c_0" }, SHOULD_SUCCEED);
    checkNodeTypes(plan, new int[] { // Access
    2, // DependentAccess
    0, // DependentSelect
    0, // DependentProject
    0, // DupRemove
    0, // Grouping
    2, // 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 89 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testRemoveRedundantDistinct.

@Test
public void testRemoveRedundantDistinct() throws Exception {
    String sql = "SELECT distinct count(*) from bqt1.smalla";
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, // $NON-NLS-1$
    RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT COUNT(*) FROM BQT1.SmallA AS g_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 90 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testNoHavingAggregate.

@Test
public void testNoHavingAggregate() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
    "select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", metadata, null, capFinder, new String[] { // $NON-NLS-1$
    "SELECT COUNT(g_0.IntKey), g_0.StringKey, MAX(g_0.IntKey) FROM BQT1.SmallA AS g_0 GROUP BY g_0.StringKey" }, ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.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 : 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

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