Search in sources :

Example 6 with RelationalPlan

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

the class TestRuleRaiseNull method testRaiseNullWithUnionAndAliases.

@Test
public void testRaiseNullWithUnionAndAliases() {
    // $NON-NLS-1$
    String sql = "select pm1.g1.e1 from pm1.g1, (select e1 from pm1.g1 where (1 = 0) union all select e1 as x from pm1.g2) x where pm1.g1.e1 <> x.e1";
    RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), // $NON-NLS-1$
    new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 <> g_1.e1" });
    TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
}
Also used : RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 7 with RelationalPlan

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

the class TestSortOptimization method testProjectionRaisingWithLimit1.

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

Example 8 with RelationalPlan

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

the class TestSortOptimization method testProjectionRaisingWithComplexOrdering.

@Test
public void testProjectionRaisingWithComplexOrdering() {
    // $NON-NLS-1$
    String sql = "select e1 || 1, e2 / 2 from pm1.g1 as x order by e1 || 1 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 LIMIT 2" }, // $NON-NLS-1$
    TestOptimizer.SHOULD_SUCCEED);
    assertTrue(plan.getRootNode() instanceof ProjectNode);
}
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) 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)

Example 9 with RelationalPlan

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

the class TestRuleMergeVirtual method testSortAliasWithSameName.

@Test
public void testSortAliasWithSameName() throws Exception {
    // $NON-NLS-1$
    String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x order by e1";
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, capFinder, // $NON-NLS-1$
    TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
    SortNode node = (SortNode) plan.getRootNode();
    // $NON-NLS-1$
    assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) SortNode(org.teiid.query.processor.relational.SortNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Example 10 with RelationalPlan

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

the class TestRuleMergeVirtual method testSortAliasWithSameNameUnion.

@Test
public void testSortAliasWithSameNameUnion() throws Exception {
    // $NON-NLS-1$
    String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x union all select e1 from pm1.g2 order by e1";
    FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
    BasicSourceCapabilities caps = new BasicSourceCapabilities();
    caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
    // $NON-NLS-1$
    capFinder.addCapabilities("pm1", caps);
    RelationalPlan plan = (RelationalPlan) TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, capFinder, // $NON-NLS-1$
    TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
    SortNode node = (SortNode) plan.getRootNode();
    // $NON-NLS-1$
    assertTrue("Alias was not accounted for in sort node", node.getElements().get(0).equals(node.getSortElements().get(0).getSymbol()));
}
Also used : FakeCapabilitiesFinder(org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder) BasicSourceCapabilities(org.teiid.query.optimizer.capabilities.BasicSourceCapabilities) SortNode(org.teiid.query.processor.relational.SortNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) Test(org.junit.Test)

Aggregations

RelationalPlan (org.teiid.query.processor.relational.RelationalPlan)40 Test (org.junit.Test)25 RelationalNode (org.teiid.query.processor.relational.RelationalNode)12 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)11 Command (org.teiid.query.sql.lang.Command)10 List (java.util.List)9 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)9 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)8 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)8 AccessNode (org.teiid.query.processor.relational.AccessNode)8 JoinNode (org.teiid.query.processor.relational.JoinNode)8 ArrayList (java.util.ArrayList)7 ProjectNode (org.teiid.query.processor.relational.ProjectNode)7 ProcessorPlan (org.teiid.query.processor.ProcessorPlan)5 Annotation (org.teiid.client.plan.Annotation)4 AnalysisRecord (org.teiid.query.analysis.AnalysisRecord)4 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)4 LanguageObject (org.teiid.query.sql.LanguageObject)4 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)3 CapabilitiesFinder (org.teiid.query.optimizer.capabilities.CapabilitiesFinder)3