Search in sources :

Example 61 with FakeCapabilitiesFinder

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

the class TestAggregatePushdown method testCase5724.

/**
 * Test to ensure count(*) isn't mistakenly pushed to either side
 */
@Test
public void testCase5724() {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("BQT2", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    ProcessorPlan plan = TestOptimizer.helpPlan(// $NON-NLS-1$
    "select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum", metadata, null, capFinder, new String[] { "SELECT g_0.IntKey, g_0.IntNum, COUNT(*) FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.IntNum", // $NON-NLS-1$ //$NON-NLS-2$
    "SELECT g_0.IntKey FROM BQT2.SmallB AS g_0" }, true);
    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) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 62 with FakeCapabilitiesFinder

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

the class TestAggregatePushdown method testJoinOr.

@Test
public void testJoinOr() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm2", caps);
    // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "SELECT A.e1 FROM pm1.g1 A, (select e2 from pm2.g1) B WHERE A.e2 = 1 OR B.e2 IS NULL GROUP BY A.e1", // $NON-NLS-1$
    RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT g_0.e2 FROM pm2.g1 AS g_0", "SELECT g_0.e2, g_0.e1 FROM pm1.g1 AS g_0 GROUP BY g_0.e2, g_0.e1" }, 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 63 with FakeCapabilitiesFinder

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

the class TestAggregatePushdown method testUserDefinedAggPushdown.

@Test
public void testUserDefinedAggPushdown() throws Exception {
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = getAggregateCapabilities();
    caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
    caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, true);
    caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
    caps.setFunctionSupport("FIRST_VALUE", true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    QueryMetadataInterface metadata = RealMetadataFactory.createTransformationMetadata(RealMetadataFactory.example1Cached().getMetadataStore(), "example1", new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
    ProcessorPlan plan = // $NON-NLS-1$
    TestOptimizer.helpPlan(// $NON-NLS-1$
    "select foo.FIRST_VALUE(e1) OVER (ORDER BY e2) from pm1.g2", // $NON-NLS-1$
    metadata, // $NON-NLS-1$
    null, // $NON-NLS-1$
    capFinder, new String[] { "SELECT foo.FIRST_VALUE(ALL g_0.e1) OVER (ORDER BY g_0.e2) FROM pm1.g2 AS g_0" }, // $NON-NLS-1$
    ComparisonMode.EXACT_COMMAND_STRING);
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) FunctionTree(org.teiid.query.function.FunctionTree) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) Test(org.junit.Test)

Example 64 with FakeCapabilitiesFinder

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

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

Aggregations

FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)544 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)513 Test (org.junit.Test)497 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)288 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)182 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)91 Command (org.teiid.query.sql.lang.Command)64 List (java.util.List)63 BigInteger (java.math.BigInteger)32 ArrayList (java.util.ArrayList)28 CommandContext (org.teiid.query.util.CommandContext)27 Schema (org.teiid.metadata.Schema)19 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)13 ColumnSet (org.teiid.metadata.ColumnSet)9 BigDecimal (java.math.BigDecimal)7 LinkedList (java.util.LinkedList)7 Column (org.teiid.metadata.Column)7 FunctionTree (org.teiid.query.function.FunctionTree)7 FakeFunctionMetadataSource (org.teiid.query.optimizer.FakeFunctionMetadataSource)6 FakeDataManager (org.teiid.query.processor.FakeDataManager)6