Search in sources :

Example 6 with ProjectNode

use of org.teiid.query.processor.relational.ProjectNode in project teiid by teiid.

the class TestSortOptimization method testProjectionRaisingWithLimit.

@Test
public void testProjectionRaisingWithLimit() {
    // Create query
    // $NON-NLS-1$
    String sql = "select e1, (select e1 from pm2.g1 where e2 = x.e2) from pm1.g1 as x order by e1 limit 2";
    RelationalPlan plan = (RelationalPlan) helpPlan(sql, RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1" }, // $NON-NLS-1$
    TestOptimizer.SHOULD_SUCCEED);
    assertTrue(plan.getRootNode() instanceof ProjectNode);
}
Also used : ProjectNode(org.teiid.query.processor.relational.ProjectNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) Test(org.junit.Test)

Example 7 with ProjectNode

use of org.teiid.query.processor.relational.ProjectNode in project teiid by teiid.

the class TestSortOptimization method testProjectionRaisingWithComplexOrdering1.

@Test
public void testProjectionRaisingWithComplexOrdering1() {
    // $NON-NLS-1$
    String sql = "select e1 || 1 as a, e2 / 2 from pm1.g1 as x order by a, e2 limit 2";
    BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
    bsc.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
    bsc.setCapabilitySupport(Capability.ROW_LIMIT, true);
    CapabilitiesFinder finder = new DefaultCapabilitiesFinder(bsc);
    RelationalPlan plan = (RelationalPlan) helpPlan(sql, RealMetadataFactory.example1Cached(), null, finder, new String[] { "SELECT concat(g_0.e1, '1') AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0, c_1 LIMIT 2" }, // $NON-NLS-1$
    TestOptimizer.SHOULD_SUCCEED);
    assertTrue(plan.getRootNode() instanceof ProjectNode);
    HardcodedDataManager hdm = new HardcodedDataManager();
    hdm.addData("SELECT concat(g_0.e1, '1') AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0, c_1 LIMIT 2", Arrays.asList("c1", 2), Arrays.asList("d1", 3));
    TestProcessor.helpProcess(plan, hdm, new List<?>[] { Arrays.asList("c1", 1), Arrays.asList("d1", 1) });
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) CapabilitiesFinder(org.teiid.query.optimizer.capabilities.CapabilitiesFinder) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) HardcodedDataManager(org.teiid.query.processor.HardcodedDataManager) ProjectNode(org.teiid.query.processor.relational.ProjectNode) DefaultCapabilitiesFinder(org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Aggregations

ProjectNode (org.teiid.query.processor.relational.ProjectNode)7 RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)7 Test (org.junit.Test)5 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)4 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)3 ArrayList (java.util.ArrayList)2 CacheID (org.teiid.dqp.internal.process.SessionAwareCache.CacheID)2 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)2 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)2 Command (org.teiid.query.sql.lang.Command)2 Reference (org.teiid.query.sql.symbol.Reference)2 List (java.util.List)1 QueryParserException (org.teiid.api.exception.query.QueryParserException)1 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)1 SourceCapabilities (org.teiid.query.optimizer.capabilities.SourceCapabilities)1 BatchedUpdatePlan (org.teiid.query.processor.BatchedUpdatePlan)1 HardcodedDataManager (org.teiid.query.processor.HardcodedDataManager)1 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)1 BatchedUpdateNode (org.teiid.query.processor.relational.BatchedUpdateNode)1 BatchedUpdateCommand (org.teiid.query.sql.lang.BatchedUpdateCommand)1