Search in sources :

Example 76 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testPushdownAvoidance.

@Test
public void testPushdownAvoidance() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
    caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    String sql = "SELECT max(bqt1.smallb.stringkey) from bqt1.smalla, bqt1.smallb where bqt1.smalla.intkey=bqt1.smallb.intkey and bqt1.smallb.bytenum <> bqt1.smalla.doublenum GROUP BY bqt1.smallb.stringnum";
    // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    sql, // $NON-NLS-1$
    RealMetadataFactory.exampleBQTCached(), new String[] { "SELECT DISTINCT g_0.IntKey AS c_0, g_0.DoubleNum AS c_1 FROM BQT1.SmallA AS g_0 ORDER BY c_0", "SELECT DISTINCT g_0.IntKey AS c_0, g_0.ByteNum AS c_1, g_0.StringNum AS c_2, g_0.StringKey AS c_3 FROM BQT1.SmallB AS g_0 ORDER BY c_0" }, capFinder, ComparisonMode.EXACT_COMMAND_STRING);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) Test(org.junit.Test)

Example 77 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testStddevAggregate.

@Test
public void testStddevAggregate() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setFunctionSupport(SourceSystemFunctions.POWER, true);
    caps.setFunctionSupport(SourceSystemFunctions.CONVERT, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm2", caps);
    // $NON-NLS-1$
    String sql = "SELECT stddev_pop(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 AS c_0, g_0.e1 AS c_1, COUNT(g_0.e2) AS c_2, SUM(power(g_0.e2, 2)) AS c_3, SUM(g_0.e2) AS c_4 FROM pm2.g1 AS g_0 GROUP BY g_0.e4, g_0.e1 ORDER BY c_0", "SELECT g_0.e4 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_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 78 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testPushDownOverUnionFiltered3.

/**
 * rand pushdown not supported
 */
@Test
public void testPushDownOverUnionFiltered3() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.ADVANCED_OLAP, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select e1, count(*) filter (where e3 > rand()) from (select e1, e2, e3 from pm1.g1 union all select e1, e2, e3 from pm1.g2) y group by e1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT g_0.e1, g_0.e3 FROM pm1.g1 AS g_0", "SELECT g_0.e1, g_0.e3 FROM pm1.g2 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 79 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testAvgAggregateFiltered.

@Test
public void testAvgAggregateFiltered() 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) filter (where y.e1 = 1) 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, g_0.e2 FROM pm2.g1 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
    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) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 80 with BasicSourceCapabilities

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

the class TestAggregatePushdown method testOuterJoinPushdown2.

@Test
public void testOuterJoinPushdown2() 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 x.e2, y.e1, count(*) from pm1.g1 x full outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1";
    ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e3, g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1 FROM pm2.g1 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 });
    HardcodedDataManager hdm = new HardcodedDataManager();
    hdm.addData("SELECT g_0.e3, g_0.e2, COUNT(*) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", Arrays.asList(true, 1, 3), Arrays.asList(true, 2, 2), Arrays.asList(null, 3, 4));
    hdm.addData("SELECT g_0.e3, g_0.e1 FROM pm2.g1 AS g_0", Arrays.asList(false, "a"), Arrays.asList(true, "b"), Arrays.asList(true, "b"));
    TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(null, "a", 1), Arrays.asList(1, "b", 6), Arrays.asList(2, "b", 4), Arrays.asList(3, null, 4) });
    // $NON-NLS-1$
    sql = "SELECT x.e2, y.e1, count(1) from pm1.g1 x full outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1";
    plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] { "SELECT g_0.e3, g_0.e2, COUNT(1) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1 FROM pm2.g1 AS g_0" }, // $NON-NLS-1$ //$NON-NLS-2$
    TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
    hdm.addData("SELECT g_0.e3, g_0.e2, COUNT(1) FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", Arrays.asList(true, 1, 3), Arrays.asList(true, 2, 2), Arrays.asList(null, 3, 4));
    TestProcessor.helpProcess(plan, hdm, new List[] { Arrays.asList(null, "a", 1), Arrays.asList(1, "b", 6), Arrays.asList(2, "b", 4), Arrays.asList(3, null, 4) });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) 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