Search in sources :

Example 81 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testAggregateOfJoinExpression.

/**
 * Note that intnum is retrieved from each source
 *
 * Note also that this test shows that the max aggregate is not placed on the bqt2 query since it would be on one of the group by expressions
 */
@Test
public void testAggregateOfJoinExpression() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
    // $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, MAX(a12.stringkey), MIN(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey GROUP BY a12.intkey";
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT g_0.StringKey, g_0.IntKey, g_0.IntNum FROM BQT2.SmallA AS g_0 GROUP BY g_0.StringKey, g_0.IntKey, g_0.IntNum", "SELECT g_0.StringKey, g_0.IntNum FROM BQT1.SmallA AS g_0" }, // $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)

Example 82 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testOuterJoinPushdown.

@Test
public void testOuterJoinPushdown() 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 count(y.e2) from pm1.g1 x left outer join pm2.g1 y on 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, 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)

Example 83 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testBusObjQuestion2HintVariation.

@Test
public void testBusObjQuestion2HintVariation() throws Exception {
    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();
    String sql = // $NON-NLS-1$
    "SELECT SUM(F.SALES), G.REGION, T.YEAR " + // $NON-NLS-1$
    "FROM SALES F MAKEDEP, GEOGRAPHY2 G, msModel.TIME T " + // $NON-NLS-1$
    "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + // $NON-NLS-1$
    "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + // $NON-NLS-1$
    "GROUP BY G.REGION, T.YEAR";
    ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] { "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msmodel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0", // $NON-NLS-1$
    "SELECT g_0.\"MONTH\", g_1.REGION, SUM(g_0.SALES) FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION" }, ComparisonMode.EXACT_COMMAND_STRING);
    checkNodeTypes(plan, new int[] { // Access
    1, // DependentAccess
    1, // 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) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 84 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testStringAggPushdown.

@Test
public void testStringAggPushdown() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_STRING, true);
    caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select string_agg(e1, ',') from pm1.g2 group by e1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT string_agg(g_0.e1, ',') FROM pm1.g2 AS g_0 GROUP BY g_0.e1" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.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 85 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testCase6211.

/**
 * Test of an aggregate nested in an expression symbol
 */
@Test
public void testCase6211() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
    // $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 sum(a11.intnum) Profit, (sum(a11.intnum) / sum(a11.floatnum)) WJXBFS2 from bqt1.smalla a11 join bqt2.smallb a12 on a11.intkey=a12.intkey group by a12.intkey";
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.exampleBQTCached(), null, capFinder, new String[] { "SELECT g_0.IntKey FROM BQT2.SmallB AS g_0", "SELECT g_0.IntKey, SUM(g_0.IntNum), SUM(g_0.FloatNum) FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey" }, // $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